結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
|
| 提出日時 | 2019-01-29 12:39:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 1,500 ms |
| コード長 | 707 bytes |
| コンパイル時間 | 857 ms |
| コンパイル使用メモリ | 75,248 KB |
| 実行使用メモリ | 9,332 KB |
| 最終ジャッジ日時 | 2024-10-09 13:45:03 |
| 合計ジャッジ時間 | 4,066 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n, m;
cin >> n >> m;
vector<int> v[n];
int a, b;
for(int i = 0; i < m; i++){
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
vector<bool> bought(n, 0);
string res = "";
for(int i = n-1; i >= 0; i--){
bool buy = false;
for(int to : v[i]){
if(to > i && !bought[to]) buy = true;
}
if(buy){
res += "1";
bought[i] = true;
}else{
res += "0";
}
}
int cur = 0;
while(res[cur] == '0') cur++;
res = res.substr(cur);
cout << res << endl;
return 0;
}