Submission #282821

#TimeUsernameProblemLanguageResultExecution timeMemory
282821Pichon5Arranging Shoes (IOI19_shoes)C++17
65 / 100
1055 ms3072 KiB
#include "shoes.h" #include <bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; long long count_swaps(std::vector<int> s) { int n=s.size(); ll res=0; int c; bool ok=true; for(int i=0;i<n/2;i++){ if(s[i]>0 or s[i+n/2]<0 or s[i]+s[i+n/2]!=0){ ok=false; break; } } if(ok==true){ n=s.size()/2; for(int i=1;i<n;i++){ res+=i; } return res; } for(int i=0;i<n;i++){ for(int l=1;l<s.size();l++){ if(s[l]+s[0]==0){ if(s[l]<0){ res+=l; }else{ res+=l-1; } s.erase(s.begin()+l); s.erase(s.begin()+0); break; } } } //2 2 1 -1 -2 return res; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int l=1;l<s.size();l++){
      |                     ~^~~~~~~~~
shoes.cpp:16:9: warning: unused variable 'c' [-Wunused-variable]
   16 |     int c;
      |         ^
#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...