Submission #233591

#TimeUsernameProblemLanguageResultExecution timeMemory
233591BasilhijazArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define mp make_pair #define pb push_back #define lp(i,s,f) for(ll i = s; i < ll(f); i++) #define inF freopen("input.in", "r", stdin); #define outF freopen("output.in", "w", stdout); #define endl '\n' #define MOD 1000000007 long long count_swaps(vector<int> s) { ll n = s.size(); if(s.size() > 2000){ n/=2; return n*(n - 1)/2; } vector<pair<int, int> > v; bool done[n]; for(int i = 0; i < n; i++){ done[i] = 0; } for(int i = 0; i < n; i++){ if(!done[i]){ int serach = s[i]*-1; int first = -1; int second = -1; first = i; for(int j = i + 1; j < n; j++){ if(s[j] == serach && !done[j]){ second = j; done[j] = 1; break; } } v.pb({first, second}); } } ll ans = 0; for(int i = 0; i < n; i++){ done[i] = 0; } for(int i = 0; i < v.size(); i++){ if(s[v[i].first] > s[v[i].second]){ ans++; } } for(int i = 0; i < v.size(); i++){ done[v[i].second] = 1; for(int j = v[i].first + 1; j < v[i].second; j++){ if(!done[j])ans++; } } return ans; } int main(){ vector<int> s; s.pb(1); s.pb(-1); cout << count_swaps(s) << endl; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:45:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++){
                    ~~^~~~~~~~~~
shoes.cpp:50:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++){
                    ~~^~~~~~~~~~
/tmp/ccbBQ5n2.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc97ZAdf.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status