結果

問題 No.1727 [Cherry 3rd Tune] Stray
ユーザー chocoruskchocorusk
提出日時 2021-09-13 22:18:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,021 ms / 6,000 ms
コード長 1,765 bytes
コンパイル時間 3,877 ms
コンパイル使用メモリ 186,424 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-16 13:43:56
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 39 ms
5,376 KB
testcase_06 AC 181 ms
5,376 KB
testcase_07 AC 1,021 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
struct unionfind{
    int cnt;
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1), cnt(n){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        cnt--;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int x[22][22];
int main()
{
    int t; cin>>t;
    int n, c;
    cin>>n>>c;
    for(int t=0; t<n; t++){
        for(int r=0; r<2; r++){
            for(int i=0; i<n; i++){
                x[t+r*n][i]=(i+t)%n+r*n;
                x[t+r*n][i+n]=(i+n-t)%n+(r^1)*n;
            }
        }
    }
    unionfind uf(1<<(2*n));
    for(int i=0; i<(1<<(2*n)); i++){
        for(int j=0; j<2*n; j++){
            int v=0;
            for(int k=0; k<2*n; k++){
                if(i&(1<<k)) v^=(1<<x[j][k]);
            }
            uf.unite(i, v);
        }
    }
    cout<<uf.cnt<<endl;
    return 0;
}
0