結果
問題 |
No.3137 Non-Intersect Chord Triangle Game
|
ユーザー |
|
提出日時 | 2025-05-29 22:53:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 2,096 bytes |
コンパイル時間 | 4,417 ms |
コンパイル使用メモリ | 304,268 KB |
実行使用メモリ | 26,852 KB |
最終ジャッジ日時 | 2025-05-29 22:53:42 |
合計ジャッジ時間 | 11,513 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 65 |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; const ll mod2 = 998244353; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll pow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; b >>= 1; a *= a; } return ans; } ll pow(ll a, ll b, ll c) { ll ans = 1; while (b) { if (b & 1) ans = (ans * a) % c; b >>= 1; a = (a * a) % c; } return ans; } void check(bool b) { if (b) cout << "Yes\n"; else cout << "No\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { ll n, m; cin >> n >> m; vector<ll>next(n+1); for (int i = 0; i < m; ++i) { ll x,y;cin>>x>>y; if (x>y)swap(x,y); next[x]=y; next[y]=-1; } vector<ll>par(n+1),sz(n+1,1); iota(par.begin(), par.end(), 0); function<ll(ll)>find=[&](ll u)->ll{ return par[u]==u?u:par[u]=find(par[u]); }; function<void(ll,ll)>unite=[&](ll u, ll v){ u=find(u); v=find(v); if (u==v)return; if (sz[u]<sz[v])swap(u,v); par[v]=u; sz[u]+=sz[v]; }; for (int i = 1; i < n+1; ++i) { if (next[i]==0){ ll z=i+1; if (z>n)z=1; while (next[z]>0){ z=next[z]+1; if (z>n)z=1; } if (next[z]==0) unite(i, z); } } bool ok=true; for (int i = 1; i <= n; ++i) { if (next[i]==0) { if (sz[find(i)]%4==2)ok=false; } } if (ok)cout<<"Aoi\n"; else cout<<"Akane\n"; } return 0; }