제출 #892727

#제출 시각아이디문제언어결과실행 시간메모리
892727Lincito_31Arranging Shoes (IOI19_shoes)C++14
45 / 100
18 ms2888 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long x=0; long long count_swaps(vector<int> s) { bool jaja=true; bool ja=true; int xx=s.size()/2; for(int i=0;i<xx;i++){ if(s[i]!=-s[i+xx]){ jaja=false; break; } } int ayu=s[0]; for(int i=0;i<s.size();i++){ if(!(s[i]==ayu || s[i]==-ayu)){ ja=false; break; } } if(jaja || ja){ vector<int> xd_po; vector<int> xd_ne; for(int i=0;i<s.size();i++){ if(s[i]<0){ if(i%2!=0){ xd_ne.push_back(i); } }else{ if(i%2==0){ xd_po.push_back(i); } } } for(int i=0;i<xd_po.size();i++){ if(xd_po[i]>xd_ne[i]){ x+=xd_po[i]-xd_ne[i]; }else{ x+=xd_ne[i]-xd_po[i]; } } }else{ while(!s.empty()){ int temp=s[0]; if(temp<0){ for(int i=1;i<s.size();i++){ if(s[i]==-temp){ x+=i-1; s.erase(s.begin()+i); break; } } s.erase(s.begin()); }else{ for(int i=1;i<s.size();i++){ if(s[i]==-temp){ x+=i; s.erase(s.begin()+i); break; } } s.erase(s.begin()); } } } return x; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int i=0;i<s.size();i++){
      |                     ~^~~~~~~~~
shoes.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i=0;i<xd_po.size();i++){
      |                     ~^~~~~~~~~~~~~
shoes.cpp:47:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |                 for(int i=1;i<s.size();i++){
      |                             ~^~~~~~~~~
shoes.cpp:56:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                 for(int i=1;i<s.size();i++){
      |                             ~^~~~~~~~~
#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...