Submission #583351

#TimeUsernameProblemLanguageResultExecution timeMemory
583351WongChun1234The Collection Game (BOI21_swaps)C++14
50 / 100
64 ms460 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 N=550; int rrl[N]; vector<pair<int,int>> sch; void solve(int n, int v) { // TODO implement this function for (int i=1;i<=n;i++) rrl[i]=i; for (int i=2-(n%2);i<=n+1;i++){ for (int j=(i%2)+1;j<n;j+=2){ schedule(rrl[j],rrl[j+1]); sch.push_back({rrl[j],rrl[j+1]}); } vector<int> res=visit(); for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){ if (res[j]){ //frnt < back, 60% must //rrl[j] now has smaller one }else{ //rrl[j] has bigger one swap(rrl[pos],rrl[pos+1]); } } sch.clear(); } /*for (int i=n-1;i>=2;i--){ for (int j=(i%2)+1;j<i;j+=2){ schedule(rrl[j],rrl[j+1]); sch.push_back({rrl[j],rrl[j+1]}); } vector<int> res=visit(); for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){ if (res[j]){ //frnt < back, 60% must //rrl[j] now has smaller one }else{ //rrl[j] has bigger one swap(rrl[pos],rrl[pos+1]); } } sch.clear(); }*/ vector<int> ans(n); for (int i=1;i<=n;i++) ans[i-1]=rrl[i]; answer(ans); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int j=0,pos=(i%2)+1;j<res.size();j++,pos+=2){
      |                            ~^~~~~~~~~~~
#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...