結果
| 問題 |
No.483 マッチ並べ
|
| コンテスト | |
| ユーザー |
char134217728
|
| 提出日時 | 2017-08-17 08:39:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,768 bytes |
| コンパイル時間 | 1,683 ms |
| コンパイル使用メモリ | 179,240 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 13:23:51 |
| 合計ジャッジ時間 | 2,793 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
17 | main(){
| ^~~~
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ti;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;
vector<ti> sat[100][2][2];
vector<pii> li[10201];
main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
FOR(i, 0, n){
int a, b;
FOR(j, 0, 2){
cin >> a >> b;
a = a * 101 + b;
li[a].pb(pii(i, j));
}
FOR(j, 0, 2){
FOR(k, 0, 2){
sat[i][j][k].pb(ti(pii(i, 1-j), 1-k));
}
}
}
FOR(i, 0, 10201){
FOR(j, 0, li[i].size()){
int f, s;
f = li[i][j].first;
s = li[i][j].second;
FOR(k, 0, li[i].size()){
if(j==k)continue;
int _f, _s;
_f = li[i][k].first;
_s = li[i][k].second;
sat[f][s][1].pb(ti(pii(_f, _s), 0));
}
}
}
set<ti> y;
queue<ti> q;
ti bad, tmp;
vector<ti> tmpv;
FOR(i, 0, n){
bool ok = false;
FOR(j, 0, 2){
bool z = false;
y.clear();
while(!q.empty())q.pop();
q.push(ti(pii(i, j), 1));
bad = ti(pii(i, j), 0);
while(!q.empty()){
tmp = q.front();
q.pop();
y.insert(tmp);
if(tmp == bad){
z = true;
break;
}
tmpv = sat[tmp.first.first][tmp.first.second][tmp.second];
for(vector<ti>::iterator itr = tmpv.begin(); itr != tmpv.end(); itr++){
if(y.find(*itr) == y.end()){
q.push(*itr);
}
}
}
if(!z)ok = true;
}
if(!ok){
cout << "NO" <<endl;
return 0;
}
}
cout << "YES" << endl;
}
char134217728