結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2022-12-05 00:15:19 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,875 bytes |
| コンパイル時間 | 3,568 ms |
| コンパイル使用メモリ | 124,808 KB |
| 最終ジャッジ日時 | 2025-02-09 05:12:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 WA * 26 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <atcoder/modint>
#include <atcoder/dsu>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<1000000007>;
bool testcase(){
int N; cin >> N;
vector<vector<int>> colors(3);
rep(i,N){
char c; int d; cin >> c >> d;
if(c == 'R') colors[0].push_back(d);
if(c == 'G') colors[1].push_back(d);
if(c == 'B') colors[2].push_back(d);
}
rep(c,3) sort(colors[c].begin(), colors[c].end());
colors.erase(remove_if(colors.begin(), colors.end(), [](const vector<int>& a){return a.empty();}), colors.end());
if(colors.size() == 1) return true;
if(colors.size() == 2){
for(int c : colors[0]) if(binary_search(colors[1].begin(), colors[1].end(), c)) return true;
return false;
}
rep(i,3){
vector<int> a0, a2;
rep(c,colors[1].size()) if(binary_search(colors[0].begin(), colors[0].end(), colors[1][c])) a0.push_back(c);
rep(c,colors[1].size()) if(binary_search(colors[2].begin(), colors[2].end(), colors[1][c])) a2.push_back(c);
if(!a0.empty() && !a2.empty()){
if(a0.size() > 1) return true;
if(a2.size() > 1) return true;
if(a0 != a2) return true;
}
swap(colors[0], colors[1]);
swap(colors[1], colors[2]);
}
return false;
}
int main(){
int T; cin >> T;
rep(i,T){
auto ans = testcase();
cout << (ans ? "YES\n" : "NO\n");
}
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia