結果

問題 No.479 頂点は要らない
ユーザー tkmst201tkmst201
提出日時 2017-05-22 22:45:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 1,500 ms
コード長 1,196 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 163,772 KB
実行使用メモリ 9,696 KB
最終ジャッジ日時 2023-10-19 14:13:52
合計ジャッジ時間 3,418 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,440 KB
testcase_01 AC 3 ms
6,440 KB
testcase_02 AC 3 ms
6,440 KB
testcase_03 AC 2 ms
6,440 KB
testcase_04 AC 4 ms
6,440 KB
testcase_05 AC 3 ms
6,440 KB
testcase_06 AC 3 ms
6,440 KB
testcase_07 AC 3 ms
6,440 KB
testcase_08 AC 3 ms
6,440 KB
testcase_09 AC 3 ms
6,440 KB
testcase_10 AC 3 ms
6,440 KB
testcase_11 AC 3 ms
6,440 KB
testcase_12 AC 3 ms
6,440 KB
testcase_13 AC 3 ms
6,440 KB
testcase_14 AC 3 ms
6,440 KB
testcase_15 AC 3 ms
6,444 KB
testcase_16 AC 3 ms
6,440 KB
testcase_17 AC 3 ms
6,440 KB
testcase_18 AC 3 ms
6,440 KB
testcase_19 AC 3 ms
6,476 KB
testcase_20 AC 4 ms
6,476 KB
testcase_21 AC 3 ms
6,448 KB
testcase_22 AC 3 ms
6,476 KB
testcase_23 AC 4 ms
6,460 KB
testcase_24 AC 4 ms
6,452 KB
testcase_25 AC 4 ms
6,464 KB
testcase_26 AC 37 ms
8,656 KB
testcase_27 AC 38 ms
8,656 KB
testcase_28 AC 33 ms
9,696 KB
testcase_29 AC 29 ms
7,828 KB
testcase_30 AC 28 ms
7,832 KB
testcase_31 AC 29 ms
7,832 KB
testcase_32 AC 29 ms
7,832 KB
testcase_33 AC 32 ms
7,796 KB
testcase_34 AC 34 ms
7,856 KB
testcase_35 AC 30 ms
7,444 KB
testcase_36 AC 18 ms
6,984 KB
testcase_37 AC 32 ms
7,932 KB
testcase_38 AC 28 ms
7,632 KB
testcase_39 AC 22 ms
7,456 KB
testcase_40 AC 23 ms
7,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |                 scanf("%d %d", &a, &b);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, m;
vector<int> g[112345];
int cnt[112345];

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a > b) swap(a, b);
		g[a].push_back(b);
	}
	
	string ans = "";
	REP(i, n) ans += '0';
	
	for (int u = n - 1; u >= 0; u--) {
		bool ok = true;
		REP(i, g[u].size()) if (ans[g[u][i]] == '0') { ok = false; break; }
		if (!ok) ans[u] = '1';
	}
	
	int last = ans.size() - 1;
	while (last >= 0 && ans[last] == '0') last--;
	last++;
	
	if (last == 0) puts("0");
	else {
		ans.erase(last);
		reverse(ALL(ans));
		cout << ans << endl;
	}
	
	return 0;
}
0