# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
807718 | Essa2006 | Arranging Shoes (IOI19_shoes) | C++14 | 16 ms | 2292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "shoes.h"
#include <cstdio>
#include <cassert>
using namespace std;
#define ll long long
#define endl '\n'
#define FF firtst
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
ll count_swaps(vector<int> S){
bool same=1;
int n=2*S.size();
for(int i=1;i<n;i++){
if(abs(S[i])!=abs(S[i-1]))
same=0;
}
if(n/2<=1000){
int ans=0;
for(int i=0;i<n;i++){
if(S[i]>0){
bool found=0;
int ind=0;
for(int j=0;j<i;j++){
if(-S[j]==S[i] && S[j+1]!=-S[i]){
found=1;
ind=j;
break;
}
}
if(found){
for(int j=i-1;j>ind;j--){
swap(S[j], S[j+1]);
ans++;
}
}
}
else if(S[i]<0){
bool found=0;
int ind=0;
for(int j=0;j<i;j++){
if(-S[j]==S[i] && (!j || S[j]!=-S[j-1])){
found=1;
ind=j;
break;
}
}
if(found){
for(int j=i-1;j>=ind;j--){
swap(S[j], S[j+1]);
ans++;
}
}
}
}
return ans;
}
if(n/2>1000 && !same){
ll ans=S.size()/2;
return ans*(ans-1)/2;
}
}
//int main() {
// int n;
// assert(1 == scanf("%d", &n));
// vector<int> S(2 * n);
// for (int i = 0; i < 2 * n; i++)
// assert(1 == scanf("%d", &S[i]));
// fclose(stdin);
//
// long long result = count_swaps(S);
//
// printf("%lld\n", result);
// fclose(stdout);
// return 0;
//}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |