結果

問題 No.479 頂点は要らない
ユーザー azbrugby
提出日時 2019-03-01 19:55:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 109 ms / 1,500 ms
コード長 1,373 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 84,076 KB
実行使用メモリ 17,208 KB
最終ジャッジ日時 2024-06-23 12:10:18
合計ジャッジ時間 4,296 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

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