提出 #75077757


ソースコード 拡げる

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using PL = pair<ll,ll>;
template <class T>
using PQ = priority_queue<T>;
template <class T>
using PQG = priority_queue<T, vector<T>, greater<T>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)(a).size()
#define pb push_back
#define eb emplace_back
#define pob pop_back
template <class T>
bool chmax(T& a, const T& b) {return (a < b ? (a = b, true) : false);}
template <class T>
bool chmin(T& a, const T& b) {return (a > b ? (a = b, true) : false);}
const int INF = 2e9;
const ll LINF = 2e18;
const vector<int> di = {-1,1,0,0}, dj = {0,0,-1,1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int q;
  cin >> q;
  rep(qi,q) {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    string ns;
    rep(i,n) {
      ns.pb(s[i]);
      if(s[i] == ')') {
        if(sz(ns)-4 < 0) continue;
        if(ns.substr(sz(ns)-4) == "(xx)") {
          rep(j,4) ns.pob();
          rep(j,2) ns.pb('x');
        }
      }
    }

    string nt;
    rep(i,m) {
      nt.pb(t[i]);
      if(t[i] == ')') {
        if(sz(nt)-4 < 0) continue;
        if(nt.substr(sz(nt)-4) == "(xx)") {
          rep(j,4) nt.pob();
          rep(j,2) nt.pb('x');
        }
      }
    }

    cout << (ns == nt ? "Yes\n" : "No\n");
  }
  return 0;
}

提出情報

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

ジャッジ結果

セット名 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 3640 KiB
01_small_00.txt AC 21 ms 3596 KiB
01_small_01.txt AC 21 ms 3608 KiB
01_small_02.txt AC 21 ms 3616 KiB
01_small_03.txt AC 21 ms 3568 KiB
01_small_04.txt AC 22 ms 3508 KiB
01_small_05.txt AC 21 ms 3716 KiB
01_small_06.txt AC 13 ms 3676 KiB
02_medium_00.txt AC 30 ms 3628 KiB
02_medium_01.txt AC 28 ms 3476 KiB
02_medium_02.txt AC 26 ms 3656 KiB
02_medium_03.txt AC 25 ms 3476 KiB
02_medium_04.txt AC 25 ms 3568 KiB
02_medium_05.txt AC 27 ms 3596 KiB
02_medium_06.txt AC 24 ms 3628 KiB
02_medium_07.txt AC 22 ms 3544 KiB
02_medium_08.txt AC 19 ms 3544 KiB
02_medium_09.txt AC 23 ms 3664 KiB
02_medium_10.txt AC 21 ms 3512 KiB
02_medium_11.txt AC 19 ms 3696 KiB
02_medium_12.txt AC 17 ms 3744 KiB
03_random_00.txt AC 17 ms 4244 KiB
03_random_01.txt AC 18 ms 4092 KiB
03_random_02.txt AC 17 ms 4368 KiB
03_random_03.txt AC 17 ms 4308 KiB
03_random_04.txt AC 18 ms 4232 KiB
03_random_05.txt AC 9 ms 4852 KiB
03_random_06.txt AC 19 ms 5480 KiB
03_random_07.txt AC 19 ms 5456 KiB
03_random_08.txt AC 19 ms 5388 KiB
03_random_09.txt AC 18 ms 5168 KiB
04_corner_00.txt AC 22 ms 7328 KiB
04_corner_01.txt AC 19 ms 7248 KiB
04_corner_02.txt AC 20 ms 8124 KiB
04_corner_03.txt AC 22 ms 8120 KiB
04_corner_04.txt AC 21 ms 7268 KiB
04_corner_05.txt AC 22 ms 7192 KiB