제출 #303563

#제출 시각아이디문제언어결과실행 시간메모리
303563vipghn2003Arranging Shoes (IOI19_shoes)C++14
50 / 100
1085 ms3200 KiB
#include<bits/stdc++.h>
#include "shoes.h"
using namespace std;

const int N=1e5+5;

long long count_swaps(vector<int>a)
{
    int n=a.size();
    long long res=0;
    for(int i=0;i<n;i+=2)
    {
        int id;
        for(int j=i+1;j<n;j++)
        {
            if(a[j]==-a[i])
            {
                id=j;
                break;
            }
        }
        for(int j=id;j>i+1;j--)
        {
            res++;
            swap(a[j],a[j-1]);
        }
        if(a[i]>0) res++;
    }
    return res;
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:13:13: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 |         int id;
      |             ^~
#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...