Submission #957749

#TimeUsernameProblemLanguageResultExecution timeMemory
957749surenArranging Shoes (IOI19_shoes)C++14
50 / 100
17 ms2000 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mk make_pair #define S second #define F first using namespace std; long long count_swaps(std::vector<int> a) { if( a.size() <= 2000 ){ ll ans = 0, srch; for(int i = 0; i < a.size(); i ++ ){ if( a[i] == 0 ) continue; for(int j = i+1; j < a.size(); j ++ ){ if( a[j] == -a[i] ){ ans += j-i; if( a[i] < 0 ) ans --; a[j] = 0; break; } if( a[j] == 0 ){ ans --; } } } return ans; } ll n = a.size()/2; ll ans = 0, r = n-1; for(int i = 0; i < n; i ++ ){ ans += r-i-1; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int i = 0; i < a.size(); i ++ ){
      |                  ~~^~~~~~~~~~
shoes.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |    for(int j = i+1; j < a.size(); j ++ ){
      |                     ~~^~~~~~~~~~
shoes.cpp:13:15: warning: unused variable 'srch' [-Wunused-variable]
   13 |   ll ans = 0, srch;
      |               ^~~~
#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...