結果
| 問題 |
No.483 マッチ並べ
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2017-02-10 23:09:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,047 bytes |
| コンパイル時間 | 3,742 ms |
| コンパイル使用メモリ | 173,664 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-29 11:00:26 |
| 合計ジャッジ時間 | 3,132 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
コンパイルメッセージ
In file included from /usr/include/string.h:535,
from /usr/include/c++/11/cstring:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:48,
from main.cpp:1:
In function ‘void* memset(void*, int, size_t)’,
inlined from ‘int main()’ at main.cpp:18:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:33: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
59 | return __builtin___memset_chk (__dest, __ch, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
60 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
int main(){
int n;
cin>>n;
P p[n][2];
map<P,vector<P> > m;
for(int i=0;i<n;i++){
cin>>p[i][0].F>>p[i][0].S>>p[i][1].F>>p[i][1].S;
m[p[i][0]].push_back(P(i,0));
m[p[i][1]].push_back(P(i,1));
}
bool u[n],f=1;
memset(u,0,sizeof(u));
for(int i=0;i<n;i++){
//if(u[i]) continue;
bool ff=0;
for(int j=0;j<2;j++){
bool v[n],w[n],fff=1;
memset(v,0,sizeof(v));
memset(w,0,sizeof(w));
w[i]=j;
queue<int> q;
q.push(i);
while(!q.empty()){
int x=q.front();q.pop();
if(v[x]) continue;
v[x]=1;
for(int k=0;k<(int)m[p[x][w[x]]].size();k++){
P np=m[p[x][w[x]]][k];
if(np.F==x) continue;
if(v[np.F]){
if(w[np.F]==np.S) fff=0;
}else{
w[np.F]=!np.S;
}
q.push(np.F);
}
}
//for(int k=0;k<n;k++) u[k]|=v[k];
ff|=fff;
}
f&=ff;
//cout<<i<<" "<<f<<endl;
}
cout<<(f?"YES":"NO")<<endl;
return 0;
}
beet