제출 #242888

#제출 시각아이디문제언어결과실행 시간메모리
242888uacoder123Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
     #include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
    #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) int(x.size())
    #define mp(i,a) make_pair(i,a)
    #define pb(a) push_back(a)
    #define bit(x,b) (x&(1LL<<b))
     
    typedef int lli;
    typedef pair <lli,lli> ii;
    typedef pair <lli,ii> iii;
    typedef vector <lli> vi;
    int segt[8*100000]={};
    void up(int node,int l,int r,int in)
    {
      if(l==r)
      {
        segt[node]=1;
        return;
      }
      int m=(l+r)/2;
      if(in<=m)
        up(2*node+1,l,m,in);
      else
        up(2*node+2,m+1,r,in);
      segt[node]=segt[2*node+1]+segt[2*node+2];
    }
    int qu(int node,int l,int r,int s,int e)
    {
      if(l>=s&&r<=e)
        return(segt[node]);
      if(l>e||r<s)
        return(0);
      int m=(l+r)/2;
      int q1=qu(2*node+1,l,m,s,e),q2=qu(2*node+2,m+1,r,s,e);
      return(q1+q2);
    }
    int64_t count_swaps(int[] S)
    {
      int n=sizeof(S)/sizeof(int),f,ans=0;
      set<ii>inva,vain;
      for(int i=0;i<2*n;++i)
      {
        f=s[i];
        if(f<0)
          f=abs(f)+n;
        inva.insert(mp(i,f));
        vain.insert(mp(f,i));
      }
      while(inva.size())
      {
        ii it,f=(*inva.begin());
        inva.erase(inva.begin());
        vain.erase(mp(f.S,f.F));
        f.F+=qu(0,0,2*n-1,f.F,2*n-1);
        if(f.S>n)
          it=(*vain.lower_bound(mp(f.S-n,0)));
        else
          it=(*vain.lower_bound(mp(f.S+n,0)));
        vain.erase(it);
        inva.erase(mp(it.S,it.F));
        it.S+=qu(0,0,2*n-1,it.S,2*n-1);
        up(0,0,2*n-1,it.S);
        ans+=it.S-f.F-1;
        if(f.S<=n)
          ans++;
      }
      return(ans);
    }

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

shoes.cpp:4:15: error: expected ',' or '...' before 'second'
     #define S second
               ^
shoes.cpp:42:31: note: in expansion of macro 'S'
     int64_t count_swaps(int[] S)
                               ^
shoes.cpp: In function 'int64_t count_swaps(int*)':
shoes.cpp:4:15: error: 'second' was not declared in this scope
     #define S second
               ^
shoes.cpp:44:20: note: in expansion of macro 'S'
       int n=sizeof(S)/sizeof(int),f,ans=0;
                    ^
shoes.cpp:4:15: note: suggested alternative: 'setns'
     #define S second
               ^
shoes.cpp:44:20: note: in expansion of macro 'S'
       int n=sizeof(S)/sizeof(int),f,ans=0;
                    ^
shoes.cpp:48:9: error: 'f' was not declared in this scope
         f=s[i];
         ^
shoes.cpp:48:11: error: 's' was not declared in this scope
         f=s[i];
           ^
shoes.cpp:68:9: error: 'ans' was not declared in this scope
         ans+=it.S-f.F-1;
         ^~~
shoes.cpp:68:9: note: suggested alternative: 'abs'
         ans+=it.S-f.F-1;
         ^~~
         abs
shoes.cpp:72:14: error: 'ans' was not declared in this scope
       return(ans);
              ^~~
shoes.cpp:72:14: note: suggested alternative: 'abs'
       return(ans);
              ^~~
              abs