Submission #289028

#TimeUsernameProblemLanguageResultExecution timeMemory
289028user202729Teams (IOI15_teams)C++17
Compilation error
0 ms0 KiB
// moreflags=grader.cpp // // 10 // :( #include "teams.h" #include<vector> #include<queue> #include<functional> #include<algorithm> //#include<cassert> std::vector<std::pair<int, int>> students; void init(int N, int A[], int B[]) { students.clear(); students.reserve(N); for(int i=0; i<N; ++i) students.push_back({A[i], B[i]}); std::sort(begin(students), end(students)); } int can(int M, int K[]) { std::sort(K, K+index); std::priority_queue<int, std::vector<int>, std::greater<int>> rights; /* rights.push(1); rights.push(2); rights.push(1); assert(rights.top()==1); rights.pop(); assert(rights.top()==1); rights.pop(); assert(rights.top()==2); rights.pop(); assert(rights.empty()); */ auto iterator=students.begin(); for(int index=0; index<M; ++index){ auto const k=K[index]; while(iterator!=students.end() and iterator->first<=k){ rights.push(iterator->second); ++iterator; } while(not rights.empty() and rights.top()<k) rights.pop(); for(int _=0; _<k; ++_){ if(rights.empty()) return 0; rights.pop(); } } return 1; } // moreflags=grader.cpp // // 10 #include "teams.h" #include<vector> #include<queue> #include<functional> #include<algorithm> std::vector<std::pair<int, int>> students; void init(int N, int A[], int B[]) { students.clear(); students.reserve(N); for(int i=0; i<N; ++i) students.push_back({A[i], B[i]}); std::sort(begin(students), end(students)); } int can(int M, int K[]) { std::priority_queue<int, std::vector<int>, std::greater<int>> rights; auto iterator=students.begin(); for(int index=0; index<M; ++index){ auto const k=K[index]; while(iterator!=students.end() and iterator->first<=k){ rights.push(iterator->second); ++iterator; } while(not rights.empty() and rights.top()<k) rights.pop(); for(int _=0; _<k; ++_){ if(rights.empty()) return 0; rights.pop(); } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:22:17: error: 'index' was not declared in this scope
   22 |  std::sort(K, K+index);
      |                 ^~~~~
teams.cpp:35:10: warning: declaration of 'index' shadows a previous local [-Wshadow]
   35 |  for(int index=0; index<M; ++index){
      |          ^~~~~
teams.cpp:22:17: note: shadowed declaration is here
   22 |  std::sort(K, K+index);
      |                 ^~~~~
teams.cpp: At global scope:
teams.cpp:61:34: error: redefinition of 'std::vector<std::pair<int, int> > students'
   61 | std::vector<std::pair<int, int>> students;
      |                                  ^~~~~~~~
teams.cpp:12:34: note: 'std::vector<std::pair<int, int> > students' previously declared here
   12 | std::vector<std::pair<int, int>> students;
      |                                  ^~~~~~~~
teams.cpp:63:6: error: redefinition of 'void init(int, int*, int*)'
   63 | void init(int N, int A[], int B[]) {
      |      ^~~~
teams.cpp:14:6: note: 'void init(int, int*, int*)' previously defined here
   14 | void init(int N, int A[], int B[]) {
      |      ^~~~
teams.cpp:70:5: error: redefinition of 'int can(int, int*)'
   70 | int can(int M, int K[]) {
      |     ^~~
teams.cpp:21:5: note: 'int can(int, int*)' previously defined here
   21 | int can(int M, int K[]) {
      |     ^~~