結果
問題 | No.1727 [Cherry 3rd Tune] Stray |
ユーザー | chocorusk |
提出日時 | 2021-09-13 21:28:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 6,000 ms |
コード長 | 1,735 bytes |
コンパイル時間 | 3,605 ms |
コンパイル使用メモリ | 187,208 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-16 13:35:33 |
合計ジャッジ時間 | 4,087 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
ソースコード
#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 main() { int t; cin>>t; while(t--){ int n, c; cin>>n>>c; ll ans=0; for(int t=0; t<n; t++){ for(int r=0; r<2; r++){ int x[22]; for(int i=0; i<n; i++){ x[i]=(i+t)%n+r*n; x[i+n]=(i+n-t)%n+(r^1)*n; } unionfind uf(2*n); for(int i=0; i<2*n; i++) uf.unite(i, x[i]); ans+=(1<<uf.cnt); } } ans/=(2*n); cout<<ans<<endl; } return 0; }