結果

問題 No.483 マッチ並べ
ユーザー beetbeet
提出日時 2017-02-10 22:59:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 160,028 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 10:37:12
合計ジャッジ時間 3,680 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:8: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
   bool u[n],f=1;
        ^
main.cpp:17:8: note: in a call to built-in allocation function ‘void* __builtin_alloca_with_align(long unsigned int, long unsigned int)’
main.cpp:18:9: warning: ‘void* memset(void*, int, size_t)’ specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   memset(u,0,sizeof(u));
   ~~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0