Submission #305987

#TimeUsernameProblemLanguageResultExecution timeMemory
305987kylych03Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #include "grader.cpp" using namespace std; long long res[200010]; int vis[200011], dp[200010]; vector <int> a[100002], b[100002]; long long count_swaps(std::vector<int> s) { long long sum = 0; for(int i = 0 ; i < s.size(); i++){ if(s[i]>0) a[s[i]].push_back(i); else b[abs(s[i])].push_back(i); } for(int i = 0 ; i <100001;i++){ for(int j = 0 ; j < a[i].size();j++){ dp[a[i][j]]=b[i][j]; dp[b[i][j]]=a[i][j]; } } for(int i = 0 ; i < s.size(); i++){ if(vis[i]==1) continue; int j=i+1; while( j!=dp[i] ){ res[j]++; j++; } sum += (j - i - 1 + (res[j] - res[i])); if(s[i] > 0) sum++; vis[dp[i]]=1; } return sum; }

Compilation message (stderr)

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