結果
問題 |
No.3234 Infinite Propagation
|
ユーザー |
![]() |
提出日時 | 2025-08-16 12:01:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 44,340 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-16 12:01:20 |
合計ジャッジ時間 | 1,196 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘pii read()’: main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%s", s); | ~~~~~^~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d", &tn); | ~~~~~^~~~~~~~~~~ main.cpp:42:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3234.cc: No.3234 Infinite Propagation - yukicoder */ #include<cstdio> #include<algorithm> #include<utility> using namespace std; /* constant */ const int MAX_L = 200000; const int INF = 1 << 30; /* typedef */ using pii = pair<int,int>; /* global variables */ char s[MAX_L + 4]; /* subroutines */ pii read() { scanf("%s", s); int cs[2] = {}; for (int i = 0; s[i]; i++) cs[s[i] - 'a']++; return {cs[0], cs[1]}; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); bool ok = false; int b0 = 0, b1 = INF, b2 = INF; for (int i = 0; i < n; i++) { auto [xa, xb] = read(); auto [ya, yb] = read(); if (xa == 1 && xb == 0) { // 'a' if (ya > 0) ok = true; else b0 = max(b0, yb); } else if (xa == 0 && xb > 0) { // 'bbb..' if (ya > 0) b1 = min(b1, xb); else b2 = min(b2, xb); } } //printf(" b0=%d,b1=%d,b2=%d\n", b0, b1, b2); if (b0 >= b2) b0 = INF; if (b0 >= b1) ok = true; if (ok) puts("Yes"); else puts("No"); } return 0; }