結果
| 問題 |
No.479 頂点は要らない
|
| コンテスト | |
| ユーザー |
bj_k28
|
| 提出日時 | 2017-01-28 01:20:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 214 ms / 1,500 ms |
| コード長 | 1,390 bytes |
| コンパイル時間 | 1,467 ms |
| コンパイル使用メモリ | 165,532 KB |
| 実行使用メモリ | 10,280 KB |
| 最終ジャッジ日時 | 2024-12-23 18:44:37 |
| 合計ジャッジ時間 | 4,469 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;
VVI edges(100010);
VB buy(100010, true);
int n, m;
VI as, bs;
string solve() {
string ans;
rrep (i, n) {
buy[i] = false;
rep (j, edges[i].size()) {
int idx = edges[i][j]; // 頂点iからいける頂点idx
if (!buy[idx]) {
buy[i] = true;
continue;
}
}
}
rep (i, n) {
ans = (buy[i]? '1' : '0') + ans;
}
rep (i, n) {
if (ans[i] == '1') {
return ans.substr(i);
}
}
return "0";
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
rep (i, m) {
int a, b;
cin >> a >> b;
as.pb(a);
bs.pb(b);
edges[a].pb(b);
edges[b].pb(a);
}
cout << solve() << endl;
return 0;
}
bj_k28