제출 #541548

#제출 시각아이디문제언어결과실행 시간메모리
541548MohamedFaresNebili마상시합 토너먼트 (IOI12_tournament)C++14
0 / 100
1093 ms1848 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast") #pragma GCC target ("avx2") using namespace std; using ll = long long; using ii = pair<ll, ll>; #define ff first #define ss second #define pb push_back /// #define int ll const int MOD = 1e9 + 7; int par[100001], mx[100001]; int findSet(int v) { if(par[v] == v) return v; return par[v] = findSet(par[v]); } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { int res = 0, curr = 0; vector<ii> query; vector<int> s; for(int l = 0; l < N; l++) s.push_back(l); for(int l = 0; l < C; l++) { int lf = S[l], rf = E[l]; query.pb({s[lf], s[rf]}); s.erase(s.begin() + lf + 1, s.begin() + rf + 1); } for(int l = 0; l < N; l++) { for(int i = 0; i < l; i++) par[i] = i, mx[i] = K[i]; par[l] = l; mx[l] = R; for(int i = l; i < N - 1; i++) par[i + 1] = i + 1, mx[i + 1] = K[i]; int calc = 0; for(auto u : query) { int lf = u.ff, rf = u.ss; lf = findSet(lf), rf = findSet(rf); if(lf > rf) swap(lf, rf); if(lf == rf) continue; par[rf] = lf; mx[lf] = max(mx[lf], mx[rf]); if(mx[lf] == R) calc++; } if(calc > curr) { curr = calc, res = l; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...