제출 #717504

#제출 시각아이디문제언어결과실행 시간메모리
717504josanneo22Arranging Shoes (IOI19_shoes)C++17
50 / 100
1081 ms2636 KiB
#include "shoes.h" #include<bits/stdc++.h> #include <vector> #include <deque> #include <iostream> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size(); bool sub4=true; for(int i=0;i<n;i++){ if(s[i]>0) sub4=false; } for(int i=n;i<2*n;i++){ if(s[i]<0) sub4=false; } if(n == 1){ if(s[0] < 0) return 0; else return 1; } else if(sub4){ long long swaps = 0; for(int i = 0; i < n; i++) swaps += i; return swaps; } else{ long long count = 0; deque<int> sc(s.size()); for(int i = 0; i<s.size(); i++)sc[i] = s[i]; while(!sc.empty()) { int x = sc.front(); sc.pop_front(); int pos = 0; for(int i = 0; i<sc.size(); i++) { if(sc[i] == x*-1) { pos = i; break; } } count+=pos+1; if(x < 0)count--; sc.erase(sc.begin()+pos); } return count; } return 0; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i = 0; i<s.size(); i++)sc[i] = s[i];
      |                  ~^~~~~~~~~
shoes.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int i = 0; i<sc.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...