Submission #253453

#TimeUsernameProblemLanguageResultExecution timeMemory
253453BadrangiikhArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include <deque> #include <cmath> using namespace std; #define ll long long /*freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);*/ int count_swaps ( vector < int > s ) { long long n = s . size ( ) ; if ( n == 2 ) { if ( s [ 0 ] < s [ 1 ] ) return 0 ; else return 1 ; } long long x = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( abs ( s [ i ] ) == abs ( s [ 0 ] ) ) x ++ ; } if ( x + 1 == n ) { long long y = 0 ; long long z = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] < 0 ) { z += abs ( i - y ) ; y += 2 ; } } return z ; } long long n = s . size ( ) / 2 ; return ( n - 1 ) * n / 2 ; }

Compilation message (stderr)

shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:18:11: error: 'i' was not declared in this scope
     for ( i = 1 ; i < n ; i ++ ) {
           ^
shoes.cpp:24:15: error: 'i' was not declared in this scope
         for ( i = 0 ; i < n ; i ++ ) {
               ^
shoes.cpp:32:15: error: redeclaration of 'long long int n'
     long long n = s . size ( ) / 2 ;
               ^
shoes.cpp:12:15: note: 'long long int n' previously declared here
     long long n = s . size ( ) ;
               ^