結果

問題 No.479 頂点は要らない
ユーザー azbrugbyazbrugby
提出日時 2019-03-01 19:55:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 119 ms / 1,500 ms
コード長 1,373 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 83,648 KB
実行使用メモリ 17,328 KB
最終ジャッジ日時 2023-09-05 16:40:51
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,512 KB
testcase_01 AC 6 ms
10,388 KB
testcase_02 AC 6 ms
10,376 KB
testcase_03 AC 6 ms
10,680 KB
testcase_04 AC 6 ms
10,404 KB
testcase_05 AC 6 ms
10,428 KB
testcase_06 AC 6 ms
10,388 KB
testcase_07 AC 6 ms
10,368 KB
testcase_08 AC 6 ms
10,404 KB
testcase_09 AC 5 ms
10,444 KB
testcase_10 AC 6 ms
10,412 KB
testcase_11 AC 6 ms
10,512 KB
testcase_12 AC 5 ms
10,384 KB
testcase_13 AC 6 ms
10,396 KB
testcase_14 AC 6 ms
10,452 KB
testcase_15 AC 5 ms
10,532 KB
testcase_16 AC 5 ms
10,496 KB
testcase_17 AC 6 ms
10,532 KB
testcase_18 AC 6 ms
10,448 KB
testcase_19 AC 7 ms
10,448 KB
testcase_20 AC 6 ms
10,432 KB
testcase_21 AC 7 ms
10,480 KB
testcase_22 AC 6 ms
10,492 KB
testcase_23 AC 7 ms
10,444 KB
testcase_24 AC 6 ms
10,636 KB
testcase_25 AC 6 ms
10,552 KB
testcase_26 AC 111 ms
17,136 KB
testcase_27 AC 112 ms
17,328 KB
testcase_28 AC 72 ms
15,776 KB
testcase_29 AC 84 ms
16,872 KB
testcase_30 AC 84 ms
16,688 KB
testcase_31 AC 84 ms
16,760 KB
testcase_32 AC 84 ms
16,772 KB
testcase_33 AC 101 ms
15,960 KB
testcase_34 AC 114 ms
16,388 KB
testcase_35 AC 119 ms
16,560 KB
testcase_36 AC 69 ms
14,404 KB
testcase_37 AC 105 ms
16,220 KB
testcase_38 AC 94 ms
15,428 KB
testcase_39 AC 64 ms
13,968 KB
testcase_40 AC 71 ms
14,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define printf printf_s
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 100000, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll n, m;
vector<ll> g1[N];
set<ll> g2[N];

int main() {
	cin >> n >> m;
	while (m--) {
		ll v1, v2; 
		cin >> v1 >> v2;
		g1[v2].pb(v1);
		g2[v1].insert(v2);
	}
	bool fst = true;
	for (int i = n - 1; i >= 0; i--) {
		if (g2[i].size() == 0) {
			if (!fst)cout << 0;
			continue;
		}
		cout << 1;
		fst = false;
		for (int i2 = 0; i2 < g1[i].size(); i2++) {
			ll ni = g1[i][i2];
			g2[ni].erase(i);
		}
	}
	cout << endl;
	return 0;
}
0