結果

問題 No.2343 (l+r)/2
ユーザー lingfunny
提出日時 2023-06-09 23:56:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 3,987 ms
コンパイル使用メモリ 281,612 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-02 06:15:39
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         for (scanf("%d", &TestCase); TestCase--;) {
      |              ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d", &n);
      |                 ~~~~~^~~~~~~~~~
main.cpp:15:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 for (int &x : a) scanf("%d", &x);
      |                                  ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using uint = unsigned;
using namespace std;

const int mxn = 2e5 + 10;

int TestCase, f[mxn][3];

signed main() {
	for (scanf("%d", &TestCase); TestCase--;) {
		int n;
		scanf("%d", &n);
		vector<int> a(n);
		for (int &x : a) scanf("%d", &x);
		vector<bool> tag;
		int last = a[0], len = 0;
		a.push_back(-1);
		for (int i = 0; i <= n; ++i) {
			if (a[i] == last) ++len;
			else {
				tag.push_back(len > 1);
				last = a[i], len = 1;
			}
		}
		auto solve = [&]() {
			// printf("size = %d\n", (int)tag.size());
			if (tag.size() % 2 == 0) return puts("Yes");
			for (int i = 1; i < (int)tag.size(); i += 2)
				if (tag[i]) return puts("Yes");
			return puts("No");
		};
		solve();
	}
	return 0;
}
0