Submission #1061113

#TimeUsernameProblemLanguageResultExecution timeMemory
106111312345678Monster Game (JOI21_monster)C++17
52 / 100
138 ms5664 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; 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]) 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]); else tmp.push_back(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++) { 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]]++; } } } //for (int i=0; i<n; i++) cout<<i<<' '<<cnt[i]<<'\n'; 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; //for (int i=0; i<n; i++) cout<<i<<' '<<res[i]<<'\n'; 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:28:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             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...