Submission #800195

#TimeUsernameProblemLanguageResultExecution timeMemory
800195fatemetmhrMonster Game (JOI21_monster)C++17
0 / 100
101 ms6056 KiB
// Be name khoda // #include "monster.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define all(x) x.begin(), x.end() #define pb push_back #define fi first #define se second #define mp make_pair namespace { const int maxn5 = 2e3 + 10; int cnt[maxn5], st[maxn5][maxn5]; bool cmp(int i, int j){return cnt[i] < cnt[j];} void msort(vector <int> &a){ if(a.size() <= 1) return; if(a.size() <= 10){ int n = a.size(); for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++){ st[a[i]][a[j]] = Query(a[i], a[j]); st[a[j]][a[i]] = st[i][j] ^ 1; } for(int i = 0; i < n; i++){ cnt[a[i]] = 0; for(int j = 0; j < n; j++) if(i != j) cnt[a[i]] += st[a[i]][a[j]]; } sort(all(a), cmp); /* for(int i = 0; i < n; i++) cout << cnt[i] << ' '; cout << endl; for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << endl; */ if(cnt[a[0]] == cnt[a[1]] && st[a[1]][a[0]]) swap(a[0], a[1]); if(cnt[a[n - 1]] == cnt[a[n - 2]] && st[a[n - 1]][a[n - 2]]) swap(a[n - 1], a[n - 2]); return; } int pt = rng() % int(a.size()); vector <int> av1, av2; for(int i = 0; i < a.size(); i++) if(i != pt){ if(Query(a[i], a[pt])) av2.pb(a[i]); else av1.pb(a[i]); } if(min(av1.size(), av2.size()) < 4){ msort(a); return; } msort(av1); msort(av2); if(av1.size() && av2.size() && Query(av1.back(), av2[0])) swap(av1[int(av1.size()) - 1], av2[0]); int keep = a[pt]; a.clear(); for(auto u : av1) a.pb(u); a.pb(keep); for(auto u : av2) a.pb(u); } } // namespace std::vector<int> Solve(int n) { vector <int> ret(n), a(n); for(int i = 0; i < n; i++) a[i] = i; msort(a); /* for(int i = 0; i < n; i++) cout << cnt[i] << ' '; cout << endl; for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << endl; //*/ /* for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << endl; */ for(int i = 0; i < n; i++){ ret[a[i]] = i; } return ret; }

Compilation message (stderr)

monster.cpp: In function 'void {anonymous}::msort(std::vector<int>&)':
monster.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i = 0; i < a.size(); i++) if(i != pt){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...