Submission #408983

#TimeUsernameProblemLanguageResultExecution timeMemory
408983ly20The Collection Game (BOI21_swaps)C++17
50 / 100
571 ms616 KiB
// // --- Sample implementation for the task swaps --- // // To compile this program with the sample grader, place: // swaps.h swaps_sample.cpp sample_grader.cpp // in a single folder and run: // g++ swaps_sample.cpp sample_grader.cpp // in this folder. // #include "swaps.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 510; vector <int> rs; int inv[MAXN]; void solve(int N, int V) { // TODO implement this function int n = N, v = V; for(int i = 1; i <= n; i++) { rs.push_back(i); inv[i] = i - 1; } for(int j = 0; j < V / 2; j++) { vector <pair <int, int> > vs; for(int i = 0; i < n; i += 2) { if(i + 1 >= n) continue; schedule(rs[i], rs[i + 1]); vs.push_back(make_pair(rs[i], rs[i + 1])); } vector <int> qr = visit(); for(int i = 0; i < vs.size(); i++) { if(qr[i] == 0) { swap(rs[inv[vs[i].first]], rs[inv[vs[i].second]]); swap(inv[vs[i].first], inv[vs[i].second]); } } vs.clear(); for(int i = 1; i < n; i += 2) { if(i + 1 >= n) continue; schedule(rs[i], rs[i + 1]); vs.push_back(make_pair(rs[i], rs[i + 1])); } qr = visit(); for(int i = 0; i < vs.size(); i++) { if(qr[i] == 0) { swap(rs[inv[vs[i].first]], rs[inv[vs[i].second]]); swap(inv[vs[i].first], inv[vs[i].second]); } } } answer(rs); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i = 0; i < vs.size(); i++) {
      |                        ~~^~~~~~~~~~~
swaps.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int i = 0; i < vs.size(); i++) {
      |                        ~~^~~~~~~~~~~
swaps.cpp:18:16: warning: unused variable 'v' [-Wunused-variable]
   18 |     int n = N, v = V;
      |                ^
#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...