結果
| 問題 |
No.479 頂点は要らない
|
| コンテスト | |
| ユーザー |
Dugong
|
| 提出日時 | 2017-03-16 20:43:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 1,500 ms |
| コード長 | 712 bytes |
| コンパイル時間 | 362 ms |
| コンパイル使用メモリ | 42,624 KB |
| 実行使用メモリ | 9,920 KB |
| 最終ジャッジ日時 | 2024-07-04 02:43:31 |
| 合計ジャッジ時間 | 2,778 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d %d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d",a+i,b+i);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> G[100000];
bool used[100000];
int ans[100000];
int main(){
int n,m;
int a[100000],b[100000];
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d %d",a+i,b+i);
G[a[i]].push_back(i);
G[b[i]].push_back(i);
}
fill(used,used+m,false);
fill(ans,ans+n,0);
for(int i=n-1;i>=0;i--){
for(int j=0;j<G[i].size();j++){
if(!used[G[i][j]]&&max(a[G[i][j]],b[G[i][j]])>i){
ans[i] = 1;
break;
}
}
if(ans[i]) for(int j=0;j<G[i].size();j++) used[G[i][j]] = true;
}
bool flag = false;
for(int i=n-1;i>=0;i--){
if(flag||ans[i]){
printf("%d",ans[i]);
flag = true;
}
}
printf("\n");
return 0;
}
Dugong