結果
問題 | No.479 頂点は要らない |
ユーザー |
![]() |
提出日時 | 2017-04-18 18:28:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,439 bytes |
コンパイル時間 | 1,477 ms |
コンパイル使用メモリ | 174,436 KB |
実行使用メモリ | 9,616 KB |
最終ジャッジ日時 | 2024-07-19 07:46:04 |
合計ジャッジ時間 | 3,196 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, j) for(int i=0; i < (int)(j); i++) #define rrep(i, j) for(int i=(j)-1; i >= 0; i--) #define all(v) v.begin(),v.end() #define debug(x) cerr << #x << " : " << x << endl template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; } class Solver { public: bool solve() { int N, M; cin >> N >> M; vector<vector<int>> E(N); rep(i, M) { int a, b; cin >> a >> b; E[a].push_back(i); E[b].push_back(i); } vector<bool> need_to_buy(N); vector<int> used_by(M, -1); rep(n, N) { bool flg = false; for(int e : E[n]) { if(used_by[e] < 0) { flg = true; used_by[e] = n; } } need_to_buy[n] = flg; } string ans = ""; rrep(n, N) if(need_to_buy[n]) { bool flg = false; for(int e : E[n]) flg |= used_by[e] == n; if(flg) { for(int e : E[n]) used_by[e] = n; } ans += flg ? "1" : "0"; if(ans == "0") ans = ""; } cout << ans << endl; return 0; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); Solver s; s.solve(); return 0; }