提出 #75089163


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int,int>;
#define endl '\n'

void solveA () {
 int l, r;
 cin >> l >> r;
 cout << r - l + 1 << endl;
}

void solveB () {
  int n, m;
  cin >> n >> m;
  unordered_map<int, int> ump;
  for (int i = 0, x; i < n; i ++) {
    cin >> x;
    ump[x] ++;
  }
  bool ok = 1;
  for (auto&[x, y] : ump) {
    if (y > 1) {
      cout << "No" << endl;
      ok = 0;
      break;
    } 
  }
  if (ok) cout << "Yes" << endl;
    if ((int)ump.size() == m) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

void solveC () {
  int n, m;
  cin >> n >> m;
  auto G = vector(n + 1, vector<int> ());
  for (int i = 0; i < m; i ++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
  }
  vector<int> vis(n + 1);
  vis[1] = 1;
  auto dfs = [&] (auto&& self, int u) -> void {
    for (auto& v : G[u]) {
      if (vis[v]) continue;
      vis[v] = 1;
      self(self, v);
    }
  };
  dfs(dfs, 1);
  cout << accumulate(vis.begin(), vis.end(), 0) << endl;
}

void solveD () {
  int t;
  cin >> t;
  while (t --) {
    string a, b;
    cin >> a >> b;
    stack<char> sta;
    for (int i = 0; i < a.length(); i++) {
        if (a[i] == ')') {
            if (sta.size() >= 3) {
                char c1 = sta.top(); sta.pop(); 
                char c2 = sta.top(); sta.pop(); 
                char c3 = sta.top(); sta.pop(); 
                if (c1 == 'x' && c2 == 'x' && c3 == '(') {
                    sta.push('x');
                    sta.push('x');
                } else {
                    sta.push(c3);
                    sta.push(c2);
                    sta.push(c1);
                    sta.push(')');
                }
            } else {
                sta.push(')');
            }
        } else {
            sta.push(a[i]);
        }
    }
    stack<char> stb;
    for (int i = 0; i < b.length(); i++) {
        if (b[i] == ')') {
            if (stb.size() >= 3) {
                char c1 = stb.top(); stb.pop();
                char c2 = stb.top(); stb.pop();
                char c3 = stb.top(); stb.pop();
                
                if (c1 == 'x' && c2 == 'x' && c3 == '(') {
                    stb.push('x');
                    stb.push('x');
                } else {
                    stb.push(c3);
                    stb.push(c2);
                    stb.push(c1);
                    stb.push(')');
                }
            } else {
                stb.push(')');
            }
        } else {
            stb.push(b[i]);
        }
    }
    string res_a = "", res_b = "";
    while (!sta.empty()) { res_a += sta.top(); sta.pop(); }
    while (!stb.empty()) { res_b += stb.top(); stb.pop(); }
    if (res_a == res_b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
  }
}

int main () {
  cin.tie(0)->sync_with_stdio(0);
  solveD();
}

提出情報

提出日時
問題 D - (xx)
ユーザ PureMilk
言語 C++23 (GCC 15.2.0)
得点 425
コード長 3032 Byte
結果 AC
実行時間 46 ms
メモリ 6436 KiB

コンパイルエラー

./Main.cpp: In function 'void solveD()':
./Main.cpp:66:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for (int i = 0; i < a.length(); i++) {
      |                     ~~^~~~~~~~~~~~
./Main.cpp:89:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |     for (int i = 0; i < b.length(); i++) {
      |                     ~~^~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 1
AC × 37
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 02_medium_00.txt, 02_medium_01.txt, 02_medium_02.txt, 02_medium_03.txt, 02_medium_04.txt, 02_medium_05.txt, 02_medium_06.txt, 02_medium_07.txt, 02_medium_08.txt, 02_medium_09.txt, 02_medium_10.txt, 02_medium_11.txt, 02_medium_12.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 04_corner_00.txt, 04_corner_01.txt, 04_corner_02.txt, 04_corner_03.txt, 04_corner_04.txt, 04_corner_05.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3532 KiB
01_small_00.txt AC 33 ms 3632 KiB
01_small_01.txt AC 33 ms 3652 KiB
01_small_02.txt AC 35 ms 3668 KiB
01_small_03.txt AC 33 ms 3608 KiB
01_small_04.txt AC 33 ms 3652 KiB
01_small_05.txt AC 33 ms 3628 KiB
01_small_06.txt AC 20 ms 3544 KiB
02_medium_00.txt AC 46 ms 3564 KiB
02_medium_01.txt AC 42 ms 3608 KiB
02_medium_02.txt AC 38 ms 3612 KiB
02_medium_03.txt AC 36 ms 3616 KiB
02_medium_04.txt AC 35 ms 3700 KiB
02_medium_05.txt AC 35 ms 3700 KiB
02_medium_06.txt AC 28 ms 3676 KiB
02_medium_07.txt AC 20 ms 3640 KiB
02_medium_08.txt AC 16 ms 3768 KiB
02_medium_09.txt AC 37 ms 3628 KiB
02_medium_10.txt AC 19 ms 3652 KiB
02_medium_11.txt AC 15 ms 3584 KiB
02_medium_12.txt AC 13 ms 3712 KiB
03_random_00.txt AC 12 ms 4320 KiB
03_random_01.txt AC 13 ms 4276 KiB
03_random_02.txt AC 12 ms 4560 KiB
03_random_03.txt AC 12 ms 4260 KiB
03_random_04.txt AC 13 ms 4252 KiB
03_random_05.txt AC 6 ms 4900 KiB
03_random_06.txt AC 12 ms 5696 KiB
03_random_07.txt AC 12 ms 5456 KiB
03_random_08.txt AC 13 ms 5408 KiB
03_random_09.txt AC 12 ms 5288 KiB
04_corner_00.txt AC 10 ms 5980 KiB
04_corner_01.txt AC 10 ms 5936 KiB
04_corner_02.txt AC 10 ms 6328 KiB
04_corner_03.txt AC 10 ms 6436 KiB
04_corner_04.txt AC 10 ms 5932 KiB
04_corner_05.txt AC 10 ms 5904 KiB