Submission #535031

#TimeUsernameProblemLanguageResultExecution timeMemory
535031devariaotaArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int tracker[s.size()+1][3]; queue <int> posi[s.size()+1][3]; bool dapat[s.size()]; memset(dapat, false, sizeof(dapat)); memset(tracker, 0, sizeof(tracker)); long long total2 = 0; for(int i = 0; i<s.size(); i++) { if(s[i] < 0) { if(tracker[abs(s[i])][2] > 0) { tracker[abs(s[i])][2]--; int b = i+1; int a = posi[abs(s[i])][2].front(); posi[abs(s[i])][2].pop(); int total1 = 0; for(int i = a+1; i<b; i++) if(!dapat[i]) total1++; total2 += b-a-total1; dapat[a] = true; dapat[b] = true; } else { tracker[abs(s[i])][1]++; posi[abs(s[i])][1].push(i); } } else { if(tracker[abs(s[i])][1] > 0) { tracker[abs(s[i])][1]--; int a = i+1; int b = posi[abs(s[i])][1].front(); posi[abs(s[i])][1].pop(); int total1 = 0; for(int i = b+1; i<a; i++) if(!dapat[i]) total1++; total2 += a-b-1-total1; dapat[a] = true; dapat[b] = true; } else { tracker[abs(s[i])][2]++; posi[abs(s[i])][2].push(i); } } } return total2; } int main() { int n; cin >> n; vector<int> vec; for(int i = 1; i<=n; i++) { int a; cin >> a; vec.push_back(a); } cout << count_swaps(vec) << endl; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = 0; i<s.size(); i++) {
      |                  ~^~~~~~~~~
/usr/bin/ld: /tmp/cca23Xpy.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoQon6x.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status