結果
問題 |
No.3234 Infinite Propagation
|
ユーザー |
|
提出日時 | 2025-08-15 21:35:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,411 bytes |
コンパイル時間 | 3,244 ms |
コンパイル使用メモリ | 279,532 KB |
実行使用メモリ | 9,440 KB |
最終ジャッジ日時 | 2025-08-15 21:36:00 |
合計ジャッジ時間 | 4,183 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,s,n) for (int i = (s); i < (n); ++i) #define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define len(x) (int)(x).size() #define dup(x,y) (((x)+(y)-1)/(y)) #define pb push_back #define eb emplace_back #define Field(T) vector<vector<T>> using namespace std; using ll = long long; using ull = unsigned long long; template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>; using P = pair<int,int>; template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;} void solve() { int n; cin >> n; vector<string> x(n), y(n); rep(i,0,n) cin >> x[i] >> y[i]; int cnt = -1; rep(i,0,n) { if (x[i] == "a") { int ok = 0; for (char c : y[i]) { if (c == 'a') ok = 1; } if (ok) { cout << "Yes" << endl; return; } else { cnt = max(cnt, len(y[i])); } } } if (cnt == -1) { cout << "No" << endl; return; } rep(i,0,n) { int cb = 0; for (char c : x[i]) cb += (c == 'b'); if (cb != len(x[i])) continue; if (cb <= cnt) { cout << "Yes" << endl; return; } } cout << "No" << endl; return; } int main() { int t; cin >> t; while(t--) solve(); return 0; }