제출 #1034207

#제출 시각아이디문제언어결과실행 시간메모리
1034207nickolasarapidisArranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms432 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<int> S){ int N = S.size(); deque<int> A(N); for(int i = 0; i < N; i++){ A[i] = S[i]; } ll ans = 0; while(N > 0){ int a = A.front(); if(a < 0 and A[1] == a + 2*a){ A.pop_front(); A.pop_front(); N -= 2; continue; } if(a < 0){ for(int i = 0; i < N; i++){ if(A[i] == a + 2*a){ int b = i; while(b != 1){ swap(A[b], A[b - 1]); b--; ans++; } } break; } A.pop_front(); A.pop_front(); N -= 2; } else{ for(int i = 0; i < N; i++){ if(A[i] == a - 2*a){ int b = i; while(b != 0){ swap(A[b], A[b - 1]); b--; ans++; } } break; } A.pop_front(); A.pop_front(); N -= 2; } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:33:22: warning: iteration 2147483648 invokes undefined behavior [-Waggressive-loop-optimizations]
   33 |       swap(A[b], A[b - 1]);
      |                    ~~^~~
shoes.cpp:32:14: note: within this loop
   32 |      while(b != 1){
      |            ~~^~~~
#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...