結果
| 問題 |
No.3234 Infinite Propagation
|
| コンテスト | |
| ユーザー |
Iroha_3856
|
| 提出日時 | 2025-08-14 20:31:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 993 bytes |
| コンパイル時間 | 3,045 ms |
| コンパイル使用メモリ | 280,620 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2025-08-14 20:31:53 |
| 合計ジャッジ時間 | 4,487 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 |
ソースコード
#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());
}
}
bool exist = false;
for (int i = 0; i < N; i++) {
if ((int)X[i].size() <= max_len and 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();
}
Iroha_3856