Submission #418930

#TimeUsernameProblemLanguageResultExecution timeMemory
418930JediMaster11Arranging Shoes (IOI19_shoes)C++17
45 / 100
36 ms3884 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vint vector<int> #define vll vector<long long> #define fo(a, b, c) for (int a = b; a < (int)c; a++) #define rfo(a, b, c) for (int a = b - 1; a >= (int)c; a--) #define print(x) cout << x << "\n" ll s2(vint s) { } ll s3(vint s) { int leftOn=0; int rightOn=1; ll sum=0; fo(i,0,s.size()){ if(s[i] > 0)//right { sum += abs(i-rightOn); rightOn+=2; }else{ sum += abs(i-leftOn); leftOn+=2; } } return sum/2; } ll s4(vint s) { ll n = (ll) s.size()/2; return (n*n-n)/2; } // s - the array of shoes, with -1 being left and 1 being right ll count_swaps(vint s) { if (s.size() == 2) return s[0] > 0 ? 1 : 0; int val = abs(s[0]); bool allSame = true; int n = s.size() / 2; bool halfed = true; fo(i, 0, n) { if (s[i] > 0 || s[i + n] < 0 || (s[i] + s[i + n] != 0)) { halfed = false; } if (abs(s[i]) != val) { allSame = false; } // if(!allSame && !halfed) break; } if (allSame) { // print("s3"); return s3(s); } if (halfed) { // print("s4"); return s4(s); } // print("other"); return s2(s); }

Compilation message (stderr)

shoes.cpp: In function 'long long int s2(std::vector<int>)':
shoes.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
   14 | }
      | ^
#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...