提出 #22013689


ソースコード 拡げる

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}

vector<vector<int>> e;
vector<int> c;
ll ans{1}, tmp;

void rec(vector<int>&g, int i=0){
    if(i==g.size()){
        ++tmp;
        return;
    }
    bool K[3]={};
    for(auto&j:e[g[i]]) if(j<g[i]){
        K[c[j]]=true;
    }
    for(int j{};j<(3);++j){
        if(!K[j]){
            c[g[i]]=j;
            rec(g,i+1);
        }
    }
}

void solve(){
    int n, m;
    cin >> n >> m;
    e.resize(n);
    dsu d(n);
    c.assign(n,-1);
    for(int i{},a,b;i<(m);++i){
        cin>>a>>b;
        --a,--b;
        if(a>b) swap(a,b);
        e[a].push_back(b);
        e[b].push_back(a);
        d.merge(a,b);
    }
    for(auto g:d.groups()){
        sort(begin(g),end(g));
        tmp=0;
        rec(g);
        ans*=tmp;
    }
    cout<<ans<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

提出情報

提出日時
問題 D - RGB Coloring 2
ユーザ Motsu_xe
言語 C++ (GCC 9.2.1)
得点 400
コード長 1191 Byte
結果 AC
実行時間 901 ms
メモリ 3712 KiB

コンパイルエラー

./Main.cpp: In function ‘void rec(std::vector<int>&, int)’:
./Main.cpp:14:9: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   14 |     if(i==g.size()){
      |        ~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 48
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All few_hen_00.txt, few_hen_01.txt, few_hen_02.txt, few_hen_03.txt, few_hen_04.txt, few_hen_05.txt, few_hen_06.txt, few_hen_07.txt, manual_00.txt, manual_01.txt, manual_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, tree_00.txt, tree_01.txt, tree_02.txt, tree_03.txt, tree_04.txt, tree_05.txt, tree_06.txt, tree_07.txt, tree_08.txt
ケース名 結果 実行時間 メモリ
few_hen_00.txt AC 12 ms 3648 KiB
few_hen_01.txt AC 2 ms 3704 KiB
few_hen_02.txt AC 2 ms 3604 KiB
few_hen_03.txt AC 2 ms 3556 KiB
few_hen_04.txt AC 2 ms 3564 KiB
few_hen_05.txt AC 1 ms 3636 KiB
few_hen_06.txt AC 2 ms 3504 KiB
few_hen_07.txt AC 2 ms 3504 KiB
manual_00.txt AC 3 ms 3548 KiB
manual_01.txt AC 2 ms 3652 KiB
manual_02.txt AC 2 ms 3668 KiB
random_00.txt AC 3 ms 3664 KiB
random_01.txt AC 5 ms 3508 KiB
random_02.txt AC 3 ms 3664 KiB
random_03.txt AC 2 ms 3556 KiB
random_04.txt AC 3 ms 3504 KiB
random_05.txt AC 2 ms 3568 KiB
random_06.txt AC 4 ms 3552 KiB
random_07.txt AC 2 ms 3616 KiB
random_08.txt AC 3 ms 3708 KiB
random_09.txt AC 3 ms 3548 KiB
random_10.txt AC 3 ms 3560 KiB
random_11.txt AC 2 ms 3684 KiB
random_12.txt AC 2 ms 3568 KiB
random_13.txt AC 2 ms 3604 KiB
random_14.txt AC 2 ms 3668 KiB
random_15.txt AC 2 ms 3560 KiB
random_16.txt AC 2 ms 3664 KiB
random_17.txt AC 2 ms 3708 KiB
random_18.txt AC 2 ms 3616 KiB
random_19.txt AC 2 ms 3656 KiB
random_20.txt AC 2 ms 3712 KiB
random_21.txt AC 2 ms 3624 KiB
random_22.txt AC 2 ms 3504 KiB
random_23.txt AC 2 ms 3552 KiB
sample_01.txt AC 3 ms 3512 KiB
sample_02.txt AC 2 ms 3708 KiB
sample_03.txt AC 2 ms 3564 KiB
sample_04.txt AC 2 ms 3556 KiB
tree_00.txt AC 15 ms 3664 KiB
tree_01.txt AC 61 ms 3696 KiB
tree_02.txt AC 54 ms 3620 KiB
tree_03.txt AC 18 ms 3604 KiB
tree_04.txt AC 3 ms 3668 KiB
tree_05.txt AC 6 ms 3504 KiB
tree_06.txt AC 901 ms 3508 KiB
tree_07.txt AC 55 ms 3556 KiB
tree_08.txt AC 32 ms 3548 KiB