Submission #7071900


Source Code Expand

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

size_t f(std::string const& s, char l1, char l2, char r1, char r2) {
  std::string t;
  for (auto c: s) {
    if (!t.empty()) {
      if (t.back() == l1 && c == l2) {
        t.back() = 'L';
        continue;
      } else if (t.back() == r1 && c == r2) {
        t.back() = 'R';
        continue;
      }
    }
    t += c;
  }
  return t.length();
}

int main() {
  char buf[262144];
  scanf("%*d %s", buf);
  std::string s = buf;

  std::string const t = "ABXY";
  size_t res = s.length();
  for (auto l1: t)
    for (auto l2: t)
      for (auto r1: t)
        for (auto r2: t)
          res = std::min(res, f(s, l1, l2, r1, r2));

  printf("%zu\n", res);
}

Submission Info

Submission Time
Task C - コマンド入力
User rsk0315
Language C++14 (GCC 5.4.1)
Score 100
Code Size 790 Byte
Status AC
Exec Time 5 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%*d %s", buf);
                       ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 45
Set Name Test Cases
All 00_retmax.txt, 00_retmin.txt, 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_twothree_00.txt, 02_twothree_01.txt, 02_twothree_02.txt, 02_twothree_03.txt, 02_twothree_04.txt, 02_twothree_05.txt, 02_twothree_06.txt, 02_twothree_07.txt, 02_twothree_08.txt, 02_twothree_09.txt, 02_twothree_10.txt, 02_twothree_11.txt, 02_twothree_12.txt, 02_twothree_13.txt, 02_twothree_14.txt, 02_twothree_15.txt, 02_twothree_16.txt, 02_twothree_17.txt, 02_twothree_18.txt, 02_twothree_19.txt
Case Name Status Exec Time Memory
00_retmax.txt AC 4 ms 256 KB
00_retmin.txt AC 1 ms 256 KB
00_sample_00.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
01_rnd_00.txt AC 5 ms 256 KB
01_rnd_01.txt AC 5 ms 256 KB
01_rnd_02.txt AC 5 ms 256 KB
01_rnd_03.txt AC 5 ms 256 KB
01_rnd_04.txt AC 5 ms 256 KB
01_rnd_05.txt AC 5 ms 256 KB
01_rnd_06.txt AC 5 ms 256 KB
01_rnd_07.txt AC 5 ms 256 KB
01_rnd_08.txt AC 5 ms 256 KB
01_rnd_09.txt AC 5 ms 256 KB
01_rnd_10.txt AC 5 ms 256 KB
01_rnd_11.txt AC 5 ms 256 KB
01_rnd_12.txt AC 5 ms 256 KB
01_rnd_13.txt AC 5 ms 256 KB
01_rnd_14.txt AC 5 ms 256 KB
01_rnd_15.txt AC 5 ms 256 KB
01_rnd_16.txt AC 5 ms 256 KB
01_rnd_17.txt AC 5 ms 256 KB
01_rnd_18.txt AC 5 ms 256 KB
01_rnd_19.txt AC 5 ms 256 KB
02_twothree_00.txt AC 4 ms 256 KB
02_twothree_01.txt AC 4 ms 256 KB
02_twothree_02.txt AC 4 ms 256 KB
02_twothree_03.txt AC 4 ms 256 KB
02_twothree_04.txt AC 4 ms 256 KB
02_twothree_05.txt AC 4 ms 256 KB
02_twothree_06.txt AC 4 ms 256 KB
02_twothree_07.txt AC 4 ms 256 KB
02_twothree_08.txt AC 4 ms 256 KB
02_twothree_09.txt AC 4 ms 256 KB
02_twothree_10.txt AC 4 ms 256 KB
02_twothree_11.txt AC 4 ms 256 KB
02_twothree_12.txt AC 4 ms 256 KB
02_twothree_13.txt AC 4 ms 256 KB
02_twothree_14.txt AC 4 ms 256 KB
02_twothree_15.txt AC 4 ms 256 KB
02_twothree_16.txt AC 4 ms 256 KB
02_twothree_17.txt AC 4 ms 256 KB
02_twothree_18.txt AC 4 ms 256 KB
02_twothree_19.txt AC 4 ms 256 KB