結果

問題 No.479 頂点は要らない
ユーザー bj_k28bj_k28
提出日時 2017-01-28 01:20:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 200 ms / 1,500 ms
コード長 1,390 bytes
コンパイル時間 1,206 ms
コンパイル使用メモリ 152,240 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2023-08-25 11:48:19
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,364 KB
testcase_01 AC 2 ms
5,336 KB
testcase_02 AC 3 ms
5,236 KB
testcase_03 AC 3 ms
5,308 KB
testcase_04 AC 3 ms
5,196 KB
testcase_05 AC 3 ms
5,420 KB
testcase_06 AC 3 ms
5,404 KB
testcase_07 AC 4 ms
5,428 KB
testcase_08 AC 3 ms
5,328 KB
testcase_09 AC 2 ms
5,364 KB
testcase_10 AC 3 ms
5,188 KB
testcase_11 AC 3 ms
5,252 KB
testcase_12 AC 3 ms
5,364 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,192 KB
testcase_15 AC 3 ms
5,328 KB
testcase_16 AC 3 ms
5,344 KB
testcase_17 AC 3 ms
5,392 KB
testcase_18 AC 3 ms
5,196 KB
testcase_19 AC 4 ms
5,196 KB
testcase_20 AC 4 ms
5,356 KB
testcase_21 AC 4 ms
5,300 KB
testcase_22 AC 3 ms
5,324 KB
testcase_23 AC 3 ms
5,532 KB
testcase_24 AC 4 ms
5,432 KB
testcase_25 AC 3 ms
5,200 KB
testcase_26 AC 195 ms
9,736 KB
testcase_27 AC 200 ms
9,692 KB
testcase_28 AC 183 ms
10,016 KB
testcase_29 AC 70 ms
8,536 KB
testcase_30 AC 70 ms
8,376 KB
testcase_31 AC 70 ms
8,404 KB
testcase_32 AC 69 ms
8,372 KB
testcase_33 AC 77 ms
8,472 KB
testcase_34 AC 82 ms
8,484 KB
testcase_35 AC 36 ms
7,736 KB
testcase_36 AC 18 ms
6,868 KB
testcase_37 AC 95 ms
8,572 KB
testcase_38 AC 61 ms
7,988 KB
testcase_39 AC 50 ms
7,548 KB
testcase_40 AC 87 ms
8,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0