Submission #404490

#TimeUsernameProblemLanguageResultExecution timeMemory
404490Theo830Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; ll INF = 1e9+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "shoes.h" long long count_swaps(std::vector<int> s){ ll m = s.size(); ll ans = 0; f(i,0,m){ ll pos = i+1; while(s[pos] != -s[i]){ pos++; } for(ll j = pos-1;j > i;j--) swap(s[j],s[j+1]); ans++; } if(s[i] > 0){ swap(s[i],s[i+1]); ans++; } i++; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:35:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |         for(ll j = pos-1;j > i;j--)
      |         ^~~
shoes.cpp:37:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |             ans++;
      |             ^~~
shoes.cpp:39:14: error: 'i' was not declared in this scope
   39 |         if(s[i] > 0){
      |              ^
shoes.cpp:43:9: error: 'i' was not declared in this scope
   43 |         i++;
      |         ^
shoes.cpp:44:5: warning: no return statement in function returning non-void [-Wreturn-type]
   44 |     }
      |     ^
shoes.cpp: At global scope:
shoes.cpp:45:5: error: expected unqualified-id before 'return'
   45 |     return ans;
      |     ^~~~~~
shoes.cpp:46:1: error: expected declaration before '}' token
   46 | }
      | ^