結果
問題 | No.479 頂点は要らない |
ユーザー |
|
提出日時 | 2017-01-28 00:17:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 1,500 ms |
コード長 | 799 bytes |
コンパイル時間 | 1,437 ms |
コンパイル使用メモリ | 175,268 KB |
実行使用メモリ | 9,764 KB |
最終ジャッジ日時 | 2024-12-23 18:04:00 |
合計ジャッジ時間 | 3,156 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef pair<int, int> P;int main() {cin.tie(0);ios::sync_with_stdio(false);int n, m;cin >> n >> m;vector<P> edges(m);vector< vector<int> > g(n);for (int i = 0; i < m; i++) {cin >> edges[i].first >> edges[i].second;g[edges[i].first].push_back(i);g[edges[i].second].push_back(i);}vector<bool> used(m, false);bool flag2 = false;for (int i = n - 1; i >= 0; i--) {bool flag = false;for (int j : g[i]) {if (used[j]) continue;if (i < edges[j].first || i < edges[j].second) {flag = true;break;}}if (flag) {for (int j : g[i]) {used[j] = true;}}if (flag && !flag2) flag2 = true;if (!flag2) continue;if (flag) cout << 1;else cout << 0;}cout << endl;return 0;}