結果

問題 No.479 頂点は要らない
ユーザー cormorancormoran
提出日時 2017-04-18 18:28:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,439 bytes
コンパイル時間 1,844 ms
コンパイル使用メモリ 172,856 KB
実行使用メモリ 9,512 KB
最終ジャッジ日時 2023-09-26 13:24:26
合計ジャッジ時間 4,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 30 ms
9,512 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0