Submission #705329

#TimeUsernameProblemLanguageResultExecution timeMemory
705329cig32The Collection Game (BOI21_swaps)C++17
85 / 100
17 ms436 KiB
#include "swaps.h" #include "bits/stdc++.h" using namespace std; int p[501], pos[501]; void block(int B, int N) { int count = 0; vector<pair<int,int> > queries; for(int k=1; k<=N; k+=(B<<1)) { for(int l=k; l<k+B; l++) { if((k<<1) + (B<<1) - 1 - l <= N) { count++; queries.push_back({p[l], p[k+k+(B<<1)-1-l]}); } } } if(queries.empty())return; for(pair<int,int> x: queries) schedule(x.first,x.second); vector<int> res = visit(); for(int i=0; i<res.size(); i++) { if(res[i] == 0) { // Then A[i] > A[j] swap(p[pos[queries[i].first]], p[pos[queries[i].second]]); for(int j=1; j<=N; j++) pos[p[j]] = j; } } } void solve(int N, int V) { // TODO implement this function for(int i=1; i<=N; i++) p[i] = pos[i] = i; int L = log2(N); for(int i=1; i<=9; i++) { int cc = 0; for(int j=(1<<L); j>=1; j>>=1) { cc++; if(cc>i+1) break; if(i==2 && j==(1<<L)/2) continue; block(j, N); } } vector<int> identity; for(int i=1; i<=N; i++) identity.push_back(p[i]); answer(identity); }

Compilation message (stderr)

swaps.cpp: In function 'void block(int, int)':
swaps.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0; i<res.size(); i++) {
      |                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...