結果

問題 No.1605 Matrix Shape
ユーザー Nzt3
提出日時 2021-07-16 23:30:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 181,116 KB
実行使用メモリ 24,344 KB
最終ジャッジ日時 2024-07-06 11:07:29
合計ジャッジ時間 5,797 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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