結果
| 問題 | 
                            No.1727 [Cherry 3rd Tune] Stray
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chocorusk
                         | 
                    
| 提出日時 | 2021-09-13 22:18:29 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 916 ms / 6,000 ms | 
| コード長 | 1,765 bytes | 
| コンパイル時間 | 3,821 ms | 
| コンパイル使用メモリ | 180,892 KB | 
| 最終ジャッジ日時 | 2025-01-24 13:45:31 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 | 
ソースコード
#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;
}
            
            
            
        
            
chocorusk