Submission #602972

#TimeUsernameProblemLanguageResultExecution timeMemory
602972Ahmadsm2005Art Collections (BOI22_art)C++17
50 / 100
949 ms668 KiB
#include "art.h" #include <bits/stdc++.h> // // --- Sample implementation for the task art --- // // To compile this program with the sample grader, place: // art.h art_sample.cpp sample_grader.cpp // in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory, // left click on "Open in terminal") and enter e.g.: // g++ -std=c++17 art_sample.cpp sample_grader.cpp // in this folder. This will create a file a.out in the current directory which you can execute from the terminal // as ./a.out // See task statement or sample_grader.cpp for the input specification // using namespace std; vector<int>GLOB; vector<int>resolve(vector<int>A,vector<int>B){ int S1 = 0, S2 = 0; int LST = publish(GLOB); vector<int>FF; while(S1 < A.size() && S2 < B.size()){ swap(GLOB[A[S1]],GLOB[B[S2]]); int F1 = publish(GLOB); swap(GLOB[A[S1]],GLOB[B[S2]]); if(F1 < LST){ FF.push_back(GLOB[B[S2]]); S2++; } else FF.push_back(GLOB[A[S1]]),S1++; } while(S1 < A.size())FF.push_back(GLOB[A[S1]]),S1++; while(S2 < B.size())FF.push_back(GLOB[B[S2]]),S2++; //cout<<A[0]<<' '<<B[0]<<endl; //for(int i = 0; i < B.size(); i += 1)cout<<B[i]<<' '; //cout<<endl; vector<int>RE = A; for(int i = 0; i < B.size(); i += 1)RE.push_back(B[i]); for(int i = 0; i < RE.size(); i += 1){ GLOB[RE[i]] = FF[i]; } return RE; } void solve(int N) { GLOB.clear(); for(int i = 0; i < N; i += 1)GLOB.push_back(i + 1); vector<vector<int>>NEW,TEMP; for(int i = 0; i < N; i += 1){ vector<int>EE; EE.push_back(i); NEW.push_back(EE); } while(NEW.size() > 1){ for(int i = 0; i < NEW.size() - 1; i += 2){ TEMP.push_back(resolve(NEW[i],NEW[i + 1])); } if(NEW.size() % 2)TEMP.push_back(NEW.back()); NEW = TEMP; //cout<<NEW.size()<<endl; TEMP.clear(); } answer(GLOB); }

Compilation message (stderr)

art.cpp: In function 'std::vector<int> resolve(std::vector<int>, std::vector<int>)':
art.cpp:21:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | while(S1 < A.size() && S2 < B.size()){
      |       ~~~^~~~~~~~~~
art.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | while(S1 < A.size() && S2 < B.size()){
      |                        ~~~^~~~~~~~~~
art.cpp:32:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 | while(S1 < A.size())FF.push_back(GLOB[A[S1]]),S1++;
      |       ~~~^~~~~~~~~~
art.cpp:33:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | while(S2 < B.size())FF.push_back(GLOB[B[S2]]),S2++;
      |       ~~~^~~~~~~~~~
art.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 | for(int i = 0; i < B.size(); i += 1)RE.push_back(B[i]);
      |                ~~^~~~~~~~~~
art.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 | for(int i = 0; i < RE.size(); i += 1){
      |                ~~^~~~~~~~~~~
art.cpp: In function 'void solve(int)':
art.cpp:54:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int i = 0; i < NEW.size() - 1; i += 2){
      |                        ~~^~~~~~~~~~~~~~~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#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...