結果

問題 No.479 頂点は要らない
ユーザー BantakoBantako
提出日時 2018-06-21 20:43:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 349 ms / 1,500 ms
コード長 1,454 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 185,908 KB
実行使用メモリ 28,056 KB
最終ジャッジ日時 2023-09-13 07:38:49
合計ジャッジ時間 8,302 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 349 ms
28,000 KB
testcase_27 AC 341 ms
28,056 KB
testcase_28 AC 177 ms
27,992 KB
testcase_29 AC 223 ms
25,696 KB
testcase_30 AC 221 ms
25,684 KB
testcase_31 AC 219 ms
25,644 KB
testcase_32 AC 225 ms
25,676 KB
testcase_33 AC 288 ms
22,580 KB
testcase_34 AC 323 ms
24,172 KB
testcase_35 AC 343 ms
23,392 KB
testcase_36 AC 202 ms
16,480 KB
testcase_37 AC 304 ms
23,576 KB
testcase_38 AC 253 ms
20,704 KB
testcase_39 AC 167 ms
15,924 KB
testcase_40 AC 186 ms
18,432 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main(){
      | ^~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:22:9: 警告: ‘maxi’ may be used uninitialized [-Wmaybe-uninitialized]
   22 |     int maxi;
      |         ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    bitset<100000> bit;
    vector<set<int> > V(N);//隣接リスト    
    set< P >edge;//残ってる辺
    map< P , int>mp;//辺を使った回数
    rep(i,0,M){
        int a,b;
        cin >> a >> b;
        V[a].insert(b);
        V[b].insert(a);
        edge.insert(P(a,b));
    }
    int maxi;
    rep(i,0,N){
        bit[i] = 1;
        for(auto j:V[i]){
            int a,b;
            a = i,b = j;
            if(a > b)swap(a,b);
            edge.erase(P(a,b));
            mp[P(a,b)]++; 
        }
        //すべての辺を使ったなら
        if(edge.empty()){
            maxi = i;
            break;
        }
    }

    for(int i = maxi;i >= 0;i--){
        //消しても問題ないか確かめる
        bool ng = 0;
        for(auto j:V[i]){
            int a,b;
            a = i,b = j;
            if(a > b)swap(a,b);
            if(mp[P(a,b)] <= 1)ng = 1; 
        }
        if(ng)continue;
        //消してもいい辺なら消す
        for(auto j:V[i]){
            int a,b;
            a = i,b = j;
            if(a > b)swap(a,b);
            mp[P(a,b)]--; 
        }
        bit[i] = 0;
    }
    for(int i = maxi;i >= 0;i--){
        cout << bit[i];
    }
    //cout << bit << endl;
}
0