Submission #886951

#TimeUsernameProblemLanguageResultExecution timeMemory
886951artixkrishnaArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define REP(i,a,b) for(int i=a; i<b; i++) int count_swaps(vector<int> a){ ll swaps=0; bool correct=false; while(!correct){ d=0; e=1; for(ll i=1; i<(int)a.size()/2; i++){ if(a[d]== -a[e]){ correct=true; d+=1; e+=1;continue; }else{ correct=false; ll b=a[e]; ll c=a[d]; a[e]=c; a[d]=b;d+=2;e+=2; swaps+=1; } } } return swaps; } int main(){ cout<<count_swaps([-2, 2, 2, -2,-2,2]); }

Compilation message (stderr)

shoes.cpp:8:5: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
    8 | int count_swaps(vector<int> a){
      |     ^~~~~~~~~~~
In file included from shoes.cpp:1:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~
shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:12:17: error: 'd' was not declared in this scope
   12 |                 d=0; e=1;
      |                 ^
shoes.cpp:12:22: error: 'e' was not declared in this scope
   12 |                 d=0; e=1;
      |                      ^
shoes.cpp: In function 'int main()':
shoes.cpp:30:28: error: expected identifier before '-' token
   30 |         cout<<count_swaps([-2, 2, 2, -2,-2,2]);
      |                            ^
shoes.cpp:30:30: error: expected ']' before ',' token
   30 |         cout<<count_swaps([-2, 2, 2, -2,-2,2]);
      |                              ^
      |                              ]
shoes.cpp: In lambda function:
shoes.cpp:30:30: error: expected '{' before ',' token
shoes.cpp: In function 'int main()':
shoes.cpp:30:45: error: expected ')' before ']' token
   30 |         cout<<count_swaps([-2, 2, 2, -2,-2,2]);
      |                          ~                  ^
      |                                             )