Submission #1304019

#TimeUsernameProblemLanguageResultExecution timeMemory
1304019lufychopArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

int n;
// vector<long long> seg(1000000,0);

long long count_swaps(vector<int> s)
{
    long long ans=0;
    int LL=0,RR=2*n-1;
    while(LL<RR)
    {
        if(s[LL]!=0)
        {
            int tmp=0;
            for(int i=LL+1;i<=RR;i++)
            {
                if(s[i]==0)
                {
                    tmp++;
                }
                if(s[i]==-s[LL])
                {
                    ans=ans+i-LL-1;
                    if(s[i]<0)
                    {
                        ans=ans+1;
                    }
                    s[i]=0;
                    s[LL]=0;
                    break;
                }
            }
        }
        if(s[RR]!=0)
        {
            int tmp=0;
            for(int i=RR-1;i>=LL;i--)
            {
                if(s[i]==0)
                {
                    tmp++;
                }
                if(s[i]==-s[RR])
                {
                    ans=ans+RR-i-1-tmp;
                    if(s[i]>0)
                    {
                        ans=ans+1;
                    }
                    s[i]=0;
                    s[RR]=0;
                    break;
                }
            }
        }
        LL++;
        RR--;
    }
	return ans;
}

int main(void)
{
    cin>>n;
    vector<int> s(2*n);
    for(int i=0;i<2*n;i++)
    {
        
        cin>>s[i];
    }
    cout<<count_swaps(s);
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccuFEQce.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctMGlLP.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status