Submission #1317280

#TimeUsernameProblemLanguageResultExecution timeMemory
1317280belmostefaArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include<vector>
using namespace std;
long long c=0;
long long count_swaps(vector<int>S){
   int l=0,r=0;
 while(l<n){
 	r++;
 	int k=-1*S[l];
 	if(k==S[r]){
 		c+=r-l-1;
 		for(int i=r;i>l+1;i--){
 			swap(S[i],S[i-1]);
 			}
 			if(S[l]>0){
 				c++;
 				swap(S[l],S[l+1]);
 				}
 			l+=2;
 		    r=l;
 		}
 	}
 	return c;
  
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:10: error: 'n' was not declared in this scope
    6 |  while(l<n){
      |          ^