結果
問題 |
No.3234 Infinite Propagation
|
ユーザー |
![]() |
提出日時 | 2025-08-14 18:45:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 3,091 ms |
コンパイル使用メモリ | 280,988 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2025-08-14 18:45:55 |
合計ジャッジ時間 | 5,129 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 15 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; bool has_a(string x) { for (char c : x) if (c == 'a') return true; return false; } void solve() { int N; cin >> N; string X[N], Y[N]; for (int i = 0; i < N; i++) cin >> X[i] >> Y[i]; int max_len = 0; for (int i = 0; i < N; i++) { if (X[i] == "a") { if (has_a(Y[i])) { cout << "Yes" << endl; return; } else { max_len = max(max_len, (int)Y[i].size()); } } } if (max_len == 0) { cout << "No" << endl; return; } int target = inf; for (int i = 0; i < N; i++) { if (has_a(X[i]) == false and has_a(Y[i]) == true) { target = min(target, (int)X[i].size()); } } if (target == inf) { cout << "No" << endl; return; } bool exist = false; for (int i = 0; i < N; i++) { if (has_a(X[i]) == false and has_a(Y[i]) == false) { exist = true; } } bool ans = ((max_len >= target) or exist); cout << (ans? "Yes" : "No") << endl; } int main() { int T; cin >> T; while(T--) solve(); }