結果
| 問題 | No.479 頂点は要らない |
| コンテスト | |
| ユーザー |
Shibuyap
|
| 提出日時 | 2020-08-03 03:16:48 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 1,500 ms |
| コード長 | 1,244 bytes |
| 記録 | |
| コンパイル時間 | 1,441 ms |
| コンパイル使用メモリ | 218,064 KB |
| 実行使用メモリ | 13,108 KB |
| 最終ジャッジ日時 | 2026-06-12 00:17:47 |
| 合計ジャッジ時間 | 4,859 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
vector<P> G[MAX_N];
int ans[MAX_N];
int use[MAX_N];
int main() {
int n, m;
cin >> n >> m;
rep(i,m){
int a, b;
cin >> a >> b;
G[a].push_back(P(b,i));
G[b].push_back(P(a,i));
}
drep(i,n){
queue<int> que;
rep(j,G[i].size()){
if(use[G[i][j].second] == 0){
use[G[i][j].second] = 1;
if(ans[G[i][j].first] == 1) continue;
que.push(G[i][j].first);
ans[G[i][j].first] = 1;
}
}
while(que.size() > 0){
int x = que.front();
que.pop();
rep(j,G[x].size()){
use[G[x][j].second] = 1;
}
}
}
int flag = 0;
drep(i,n){
if(ans[i] == 1){
flag = 1;
cout << ans[i];
}else if(flag){
cout << ans[i];
}
}
cout << endl;
return 0;
}
Shibuyap