結果
問題 | No.310 2文字しりとり |
ユーザー |
![]() |
提出日時 | 2015-12-04 23:54:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,245 bytes |
コンパイル時間 | 1,397 ms |
コンパイル使用メモリ | 163,072 KB |
実行使用メモリ | 66,048 KB |
最終ジャッジ日時 | 2024-09-14 13:33:19 |
合計ジャッジ時間 | 3,569 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef complex<double> P; typedef pair<int,int> pii; #define REP(i,n) for(ll i=0;i<n;++i) #define REPR(i,n) for(ll i=1;i<n;++i) #define FOR(i,a,b) for(ll i=a;i<b;++i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define MOD (ll)(1e9+7) #define ADD(a,b) a=((a)+(b))%MOD #define FIX(a) ((a)%MOD+MOD)%MOD int main(){ // counting eulerian circuit int n,m; cin >> n >> m; vector<vi> G(n,vi(n,1)); REP(i,m){ int a,b; cin >> a >> b; --a;--b; G[a][b] = 0; } int beg=-1,end=-1; REP(i,n){ int in = 0, out = 0; REP(j,n){ if(G[i][j]==1)in += 1; if(G[j][i]==1)out += 1; } if(in==out)continue; if(in+1==out){ if(beg==-1){ beg = i; continue; } } if(in==out+1){ if(end==-1){ end = i; continue; } } cout << 0 << endl; return 0; } if(beg==-1 && end!=-1){ cout << 0 << endl; return 0; } if(n*n==m){ cout << 1 << endl; return 0; } cout << n*n << endl; return 0; }