Submission #492336

#TimeUsernameProblemLanguageResultExecution timeMemory
492336Jarif_RahmanMonster Game (JOI21_monster)C++17
0 / 100
70 ms4228 KiB
#include "monster.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; vector<vector<int>> QQ; bool query(int a, int b){ if(a > b){ if(QQ[b][a] == -1) QQ[b][a] = Query(b, a); return !QQ[b][a]; } else{ if(QQ[a][b] == -1) QQ[a][b] = Query(a, b); return QQ[a][b]; } } template<typename it> void merge_sort(it a, it b){ int n = b-a; if(n == 1) return; merge_sort(a, a+n/2); merge_sort(a+n/2, b); int* ab = new int[n]; merge(a, a+n/2, a+n/2, b, ab, [&](int x, int y){ return query(y, x); }); for(int i = 0; i < n; i++) *(a+i) = *(ab+i); } vector<int> Solve(int n){ QQ = vector<vector<int>>(n, vector<int>(n, -1)); vector<int> sth(n); for(int i = 0; i < n; i++) sth[i] = i; merge_sort(sth.begin(), sth.end()); for(int i = 0; i < n-1; i++){ if(query(sth[i], sth[i+1])){ i++; continue; } bool bl = 0; for(int j = i+2; j < n; j++){ if(query(sth[j], sth[i])){ reverse(sth.begin()+i, sth.begin()+j); i = j-1; bl = 1; break; } } if(!bl){ swap(sth[i], sth[i+1]); i++; } } vector<int> ans(n); for(int i = 0; i < n; i++) ans[sth[i]] = i; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...