Submission #1061127

#TimeUsernameProblemLanguageResultExecution timeMemory
106112712345678Monster Game (JOI21_monster)C++17
58 / 100
122 ms4952 KiB
#include "monster.h" #include <bits/stdc++.h> using namespace std; const int nx=1005; int n, dp[nx][nx], cnt[nx], used[nx], pw[nx], x, y; set<int> s[nx]; int query(int a, int b) { if (dp[a][b]) return dp[a][b]-1; dp[a][b]=Query(a, b); dp[b][a]=!dp[a][b]; dp[a][b]++, dp[b][a]++; return dp[a][b]-1; } std::vector<int> Solve(int N) { n=N; for (int t=0; t<N; t++) { vector<int> v; for (int i=0; i<N; i++) if (!used[i]&&s[i].empty()) v.push_back(i); while (v.size()>1) { vector<int> tmp; for (int i=0; i+1<v.size(); i+=2) { if (!query(v[i], v[i+1])) tmp.push_back(v[i]), s[v[i+1]].insert(v[i]); else tmp.push_back(v[i+1]), s[v[i]].insert(v[i+1]); } if (v.size()%2) tmp.push_back(v.back()); v=tmp; } pw[t]=v[0]; used[v[0]]=1; for (int i=0; i<N; i++) if (s[i].find(v[0])!=s[i].end()) s[i].erase(v[0]); } for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { if (i==j) continue; if (i<j-10) cnt[pw[j]]++; else if (i>j+10) cnt[pw[i]]++; else { if (query(pw[i], pw[j])) cnt[pw[i]]++; else cnt[pw[j]]++; } } } vector<pair<int ,int>> v; for (int i=0; i<n; i++) v.push_back({cnt[i], i}); sort(v.begin(), v.end()); vector<int> res(n), ans(n); for (int i=0; i<n; i++) res[i]=v[i].second; if (!query(res[0], res[1])) swap(res[0], res[1]); if (!query(res[n-2], res[n-1])) swap(res[n-2], res[n-1]); for (int i=0; i<n; i++) ans[res[i]]=i; return ans; }

Compilation message (stderr)

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for (int i=0; i+1<v.size(); i+=2)
      |                           ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...