結果
| 問題 |
No.2343 (l+r)/2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-09 21:22:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,087 bytes |
| コンパイル時間 | 1,919 ms |
| コンパイル使用メモリ | 197,176 KB |
| 最終ジャッジ日時 | 2025-02-13 23:46:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 7 |
ソースコード
#ifndef hari64
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define debug(...)
#else
#include "util/viewer.hpp"
#define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif
using namespace std;
constexpr int INF = 1001001001;
constexpr long long INFll = 1001001001001001001;
template <class T>
bool chmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
template <class T>
bool chmin(T& a, const T& b) {
return a > b ? a = b, 1 : 0;
}
bool solve(int N, vector<double>& As) {
if (N == 1) {
return abs(As[0] - 0.5) < 1e-8;
}
for (int i = 0; i < N - 1; i++) {
vector<double> Bs = As;
Bs[i] += Bs[i + 1];
Bs[i] /= 2;
Bs.erase(Bs.begin() + i + 1);
if (solve(N - 1, Bs)) {
return true;
}
}
return false;
}
bool fast(int N, vector<int>& As) {
if (As[0] != As[N - 1]) {
return true;
}
if (As[0] == 1) {
for (int i = 0; i < N; i++) {
As[i] = 1 - As[i];
}
}
for (int i = 0; i < N - 1; i++) {
if (As[i] == 1 && As[i + 1] == 1) {
return true;
}
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// for (int N = 1; N < 10; N++) {
// for (int bit = 0; bit < (1 << N); bit++) {
// vector<double> As(N);
// for (int i = 0; i < N; i++) {
// As[i] = (bit >> i) & 1;
// }
// vector<int> _As(N);
// for (int i = 0; i < N; i++) {
// _As[i] = As[i];
// }
// if (!solve(N, As)) {
// debug(N, _As);
// }
// assert(solve(N, As) == fast(N, _As));
// }
// }
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> As(N);
for (int i = 0; i < N; i++) {
cin >> As[i];
}
cout << (fast(N, As) ? "Yes" : "No") << endl;
}
return 0;
}