結果
| 問題 |
No.1605 Matrix Shape
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-16 23:22:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 649 bytes |
| コンパイル時間 | 1,662 ms |
| コンパイル使用メモリ | 178,108 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 10:57:06 |
| 合計ジャッジ時間 | 5,005 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 12 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
int N;
cin>>N;
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]--;
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){
sort(E.begin(),E.end());
E.erase(unique(E.begin(),E.end()),E.end());
cout<<E.size()<<'\n';
}else{
cout<<ans<<'\n';
}
}