結果

問題 No.1605 Matrix Shape
ユーザー Nzt3Nzt3
提出日時 2021-07-16 23:30:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 177,412 KB
実行使用メモリ 24,492 KB
最終ジャッジ日時 2023-09-20 16:01:41
合計ジャッジ時間 6,691 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
13,112 KB
testcase_01 AC 9 ms
13,128 KB
testcase_02 AC 8 ms
13,124 KB
testcase_03 AC 8 ms
13,044 KB
testcase_04 WA -
testcase_05 AC 9 ms
13,024 KB
testcase_06 AC 9 ms
13,044 KB
testcase_07 AC 8 ms
12,980 KB
testcase_08 WA -
testcase_09 AC 7 ms
13,092 KB
testcase_10 AC 8 ms
13,032 KB
testcase_11 AC 8 ms
13,132 KB
testcase_12 WA -
testcase_13 AC 8 ms
13,020 KB
testcase_14 AC 8 ms
13,260 KB
testcase_15 AC 8 ms
13,364 KB
testcase_16 AC 7 ms
13,220 KB
testcase_17 AC 9 ms
13,260 KB
testcase_18 AC 7 ms
13,392 KB
testcase_19 AC 193 ms
24,252 KB
testcase_20 WA -
testcase_21 AC 175 ms
24,060 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 170 ms
24,244 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 171 ms
23,936 KB
testcase_28 WA -
testcase_29 AC 165 ms
23,964 KB
testcase_30 WA -
testcase_31 AC 173 ms
24,288 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 108 ms
14,628 KB
testcase_35 AC 132 ms
22,108 KB
testcase_36 AC 79 ms
18,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
  int N;
  cin>>N;
  vector<set<int>>V(200000);
  vector<int>cnt(200000);
  vector<array<int,2>>E(N);
  for(int i=0;i<N;i++){
    cin>>E[i][0]>>E[i][1];
    E[i][0]--,E[i][1]--;
    V[E[i][0]].insert(E[i][1]);
    cnt[E[i][0]]++;
    cnt[E[i][1]]--;
  }
  long long ans=0;
  bool cycle=false;
  sort(cnt.begin(),cnt.end());
  if(cnt[0]==0&&cnt[200000-1]==0)cycle=true;
  if(cnt[0]==-1&&cnt[200000-1]==1){
    ans=1;
    for(int i=1;i<N-1;i++){
      if(cnt[i]!=0)ans=0;
    }
  }
  if(cycle){
    ans=0;
    for(auto i:V)ans+=i.size();
  }
  cout<<ans<<'\n';
}
0