結果

問題 No.479 頂点は要らない
ユーザー tkmst201tkmst201
提出日時 2017-05-22 22:31:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 1,500 ms
コード長 1,437 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 165,676 KB
実行使用メモリ 10,584 KB
最終ジャッジ日時 2023-10-19 14:13:31
合計ジャッジ時間 4,781 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,440 KB
testcase_01 AC 3 ms
6,440 KB
testcase_02 AC 3 ms
6,444 KB
testcase_03 AC 3 ms
6,440 KB
testcase_04 AC 2 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,444 KB
testcase_14 AC 3 ms
6,444 KB
testcase_15 AC 2 ms
6,444 KB
testcase_16 AC 3 ms
6,444 KB
testcase_17 AC 3 ms
6,444 KB
testcase_18 AC 3 ms
6,444 KB
testcase_19 AC 3 ms
6,480 KB
testcase_20 AC 3 ms
6,492 KB
testcase_21 AC 3 ms
6,480 KB
testcase_22 AC 3 ms
6,480 KB
testcase_23 AC 3 ms
6,488 KB
testcase_24 AC 3 ms
6,492 KB
testcase_25 AC 3 ms
6,476 KB
testcase_26 AC 47 ms
10,084 KB
testcase_27 AC 50 ms
10,084 KB
testcase_28 AC 32 ms
10,584 KB
testcase_29 AC 35 ms
9,716 KB
testcase_30 AC 35 ms
9,712 KB
testcase_31 AC 35 ms
9,716 KB
testcase_32 AC 35 ms
9,712 KB
testcase_33 AC 44 ms
9,836 KB
testcase_34 AC 50 ms
10,068 KB
testcase_35 AC 40 ms
9,636 KB
testcase_36 AC 21 ms
8,324 KB
testcase_37 AC 47 ms
10,104 KB
testcase_38 AC 37 ms
9,504 KB
testcase_39 AC 27 ms
8,792 KB
testcase_40 AC 33 ms
9,372 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<pii> g[112345];
int done[112345];

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(pii(b, i));
		g[b].push_back(pii(a, i));
	}
	
	string ans = "";
	REP(i, n) ans += '0';
	
	for (int u = n - 1; u >= 0; u--) {
		bool ok = true;
		REP(i, g[u].size()) if (!done[g[u][i].se]) { ok = false; break; }
		if (ok) continue;
		
		REP(i, g[u].size()) {
			int v = g[u][i].fi;
			
			ok = true;
			REP(j, g[v].size()) if (!done[g[v][j].se]) { ok = false; break; }
			if (ok) continue;
			
			ans[v] = '1';
			
			REP(j, g[v].size()) done[g[v][j].se] = true;
		}
	}
	
	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