Submission #5399318


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

struct Match {
  int start;
  int end;
};

int max_tapes(const std::string& str) {
  std::vector<Match> matches;
  for (int k=0; k<=str.size()-5; k++) {
    if (str.substr(k, 5) == "tokyo" || str.substr(k, 5) == "kyoto") {
      matches.push_back({k, k+5});
    }
  }
  std::sort(std::begin(matches), std::end(matches),
      [](const Match& lhs, const Match& rhs) { return lhs.end < rhs.end; });
  int cur_time = 0;
  int cnt = 0;
  for (int i=0; i<matches.size(); i++) {
    if (matches[i].start < cur_time) continue;
    cur_time = matches[i].end;
    cnt++;
  }
  return cnt;
}

int main() {
  int T;
  std::cin >> T;
  std::vector<std::string> S(T);
  for (int i=0; i<T; i++) std::cin >> S[i];
  for (int i=0; i<T; i++) {
    std::cout << max_tapes(S[i]) << std::endl;
  }
}

Submission Info

Submission Time
Task A - 東京都
User Ktakuya
Language C++14 (GCC 5.4.1)
Score 0
Code Size 894 Byte
Status RE
Exec Time 97 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 2
RE × 1
Set Name Test Cases
All 10_random_to_kyo.txt, 20_noised_tokyoto.txt, 99_teuchi.txt
Case Name Status Exec Time Memory
10_random_to_kyo.txt AC 3 ms 256 KB
20_noised_tokyoto.txt AC 3 ms 256 KB
99_teuchi.txt RE 97 ms 256 KB