Submission #1140483

#TimeUsernameProblemLanguageResultExecution timeMemory
1140483tsengangArranging Shoes (IOI19_shoes)C++20
10 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll int #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define pb push_back #define ertunt return #define vodka void #include "shoes.h" long long count_swaps(vector<int> s) { ll n = s.size()/2; if(n == 1){ if(s[0] < 0)ertunt 0; else ertunt 1; } vector<ll> adj[n+4][2]; map<ll,ll>m; for(ll i = 0; i < s.size(); i++){ m[abs(s[i])] = 1; if(s[i] < 0){ adj[abs(s[i])][0].pb(i); } else adj[s[i]][1].pb(i); } ll cnt = 0; ll k = -1; long long ans = 0; for(auto [x,y] : m){ cnt++; k = x; for(ll i = 0; i < adj[x][0].size(); i++){ if(adj[x][0][i] < adj[x][1][i]){ ans+=adj[x][1][i] - adj[x][0][i] - 1; } else{ ans+=adj[x][0][i] - adj[x][1][i] - 2; } } } if(cnt == 1){ ertunt ans; } }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
#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...