Submission #492335

#TimeUsernameProblemLanguageResultExecution timeMemory
492335Jarif_RahmanMonster Game (JOI21_monster)C++17
10 / 100
227 ms4208 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]; } } vector<int> Solve(int n){ QQ = vector<vector<int>>(n, vector<int>(n, -1)); vector<int> cnt(n, 0), sth(n); for(int i = 0; i < n; i++) sth[i] = i; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(i != j && query(i, j)) cnt[i]++; sort(sth.begin(), sth.end(), [&](int a, int b){ return cnt[a] < cnt[b]; }); if(query(sth[1], sth[0])) swap(sth[1], sth[0]); if(query(sth[n-1], sth[n-2])) swap(sth[n-1], sth[n-2]); 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...