제출 #143864

#제출 시각아이디문제언어결과실행 시간메모리
143864Bodo171Arranging Shoes (IOI19_shoes)C++14
50 / 100
1087 ms19192 KiB
#include "shoes.h" #include <vector> #include <iostream> #include <algorithm> using namespace std; const int nmax=200005; vector<int> v[2][nmax]; struct pr { int x,y; }a[nmax]; bool comp(pr unu,pr doi) { return ((unu.x+unu.y)<(doi.x+doi.y)); } int fin[nmax],po[nmax]; int nr,i,j,mn,col,poz; int abss(int x) { if(x<0) return -x; return x; } long long count_swaps(vector<int> s) { int n=s.size(); n/=2;int ans=0; for(int i=0;i<2*n;i++) { v[(s[i]>0)][abss(s[i])].push_back(i); } ans=0; for(i=1;i<=n;i++) { for(j=0;j<v[0][i].size();j++) { a[nr++]={v[0][i][j],v[1][i][j]}; } } sort(a,a+nr,comp); for(i=0;i<nr;i++) { fin[a[i].x]=2*i; fin[a[i].y]=2*i+1; } for(i=0;i<2*n;i++) for(j=i+1;j<2*n;j++) ans+=(fin[i]>fin[j]); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0;j<v[0][i].size();j++)
                 ~^~~~~~~~~~~~~~~
shoes.cpp:44:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=0;i<2*n;i++)
     ^~~
shoes.cpp:47:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return ans;
  ^~~~~~
#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...