結果

問題 No.310 2文字しりとり
ユーザー rickythetarickytheta
提出日時 2015-12-04 23:54:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,245 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 148,256 KB
実行使用メモリ 65,880 KB
最終ジャッジ日時 2023-10-12 14:41:10
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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