제출 #1285229

#제출 시각아이디문제언어결과실행 시간메모리
1285229goulthenPermutation Game (APIO25_permgame)C++20
6 / 100
2 ms352 KiB
#include "permgame.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i <= b; ++i) #define pb push_back #define fi first #define se second #define pii pair<int,int> int Alice(int m, int e, std::vector<int> u, std::vector<int> v, int n, std::vector<int> p) { int cnt = 0; rep(i,0,n-1) if (p[i]==i) cnt++; vector<int> deg(m); rep(i,0,e-1) deg[u[i]]++, deg[v[i]]++; rep(i,0,m-1) if(deg[i] > 2) return cnt; while(1){ pii cur = {-1,-1}; vector<bool> mk(n+1,0); rep(i,0,n-1) { if(mk[i]) continue; mk[i] = 1; int st = p[i],sz = 1; while (!mk[st]){ sz++; st = p[st]; } cur = max(cur,{sz,i}); } if(cur.fi < m) break; cnt++; vector<int> t; t.pb(cur.se); rep(i,1,m-1) { t.pb(p[t.back()]); } int j = Bob(t); swap(p[t[u[j]]], p[t[v[j]]]); } return cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...