結果

問題 No.479 頂点は要らない
ユーザー maimai
提出日時 2016-10-11 13:09:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,368 bytes
コンパイル時間 3,615 ms
コンパイル使用メモリ 174,000 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-24 20:04:54
合計ジャッジ時間 5,941 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

// 参考:全探索O(2^n)

int main(){
    int n,m;
    int i,j,k;
    int a,b;
    
    cin >> n>>m;
    assert(2<=n && n<=150);
    assert((n+1)/2<=m && m<=n*(n-1)/2 && m<=1000);
    
    vector<vector<int>> vertex(n);
    
    for (i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        assert(0<=a && a<n);
        assert(0<=b && b<n);
        assert(a<=b);
        // edgeset[i][1]=b;
        // edgeset[i][0]=a;
        vertex[a].emplace_back(i);
        vertex[b].emplace_back(i);
    }
    
    
    if (15<n){
        cout<<"surrender"<<endl;
        return 0;
    }
    
    int result=-1;
    for (int bits=0;bits < 1<<n;bits++){
        vector<bool> check(m,false);
        int count = 0;
        for (i=0;0 < bits>>i;i++){
            if ((bits>>i)&1){
                for(int e:vertex[i]){
                    if (!check[e]){
                        check[e]=true;
                        count++;
                    }
                }
            }
        }
        if (count==m){
            result = bits;
            break;
        }
    }
    
    // cout << result << endl;
    
    stack<char> stack;
    while (result){
        stack.push((result&1)+'0');
        result>>=1;
    }
    while (!stack.empty()){
        cout << stack.top();
        stack.pop();
    }
    cout << endl;

    return 0;
}
0