結果

問題 No.3234 Infinite Propagation
ユーザー GOTKAKO
提出日時 2025-08-15 21:31:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 194,376 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 21:31:43
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

    int T; cin >> T;
    while(T--){
        int N; cin >> N;
        int needb = 1001001001,maxb = 0;
        bool ok = false;
        while(N--){
            string s,t; cin >> s >> t;
            if(s == "a"){
                int bs = 0;
                for(auto c : t) bs += c=='b';
                if(bs == t.size()) maxb = max(maxb,(int)t.size());
                else ok = true;
            }
            else{
                int bs = 0;
                for(auto c : s) bs += c=='b';
                if(bs == s.size()) needb = min(needb,(int)s.size());
            }
        }
        if(maxb >= needb) ok = true;
        if(ok) cout << "Yes\n";
        else cout << "No\n";
    }
}
0