제출 #253502

#제출 시각아이디문제언어결과실행 시간메모리
253502ErkhemkhuuArranging Shoes (IOI19_shoes)C++17
85 / 100
94 ms6776 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const ll N = 5005; ll count_swaps(vector <int> vc) { ll n, i, res, cur, j, k; n = vc.size(); set <ll> cnt; for(auto &x: vc) cnt.insert(abs(x)); res = 0; if(cnt.size() == 1) { vector <ll> left; for(i = 0; i < n; i++) if(vc[i] < 0) left.pb(i); for(i = 0; i < n / 2; i++) res += (abs(left[i] - (i + i))); return res; } if(n <= N) { for(i = 0; i < n; i += 2) { for(j = i + 1; j < n; j++) { if(-vc[i] == vc[j]) { for(k = j; k >= i + 2; k--) { swap(vc[k], vc[k - 1]); res++; } break; } } res += (!(abs(vc[i]) == abs(vc[i + 1]) && vc[i] < vc[i + 1])); } return res; } res = 1ll * (n / 2) * ((n / 2) - 1) / 2; return res; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:19: warning: unused variable 'cur' [-Wunused-variable]
     ll n, i, res, cur, j, k;
                   ^~~
#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...