답안 #713089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713089 2023-03-21T03:55:45 Z lam Unscrambling a Messy Bug (IOI16_messy) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#include "messy.h"
using namespace std;
vector <int> res;
string S;
inline string tostring(ll x, int n)
{
    string s="";
    for (int i=0; i<n; i++)
    {
        if (x%2LL==0) s+='0';
        else s+='1';
        x/=2LL;
    }
    return s;
}
void build(int lx, int rx)
{
    if (lx==rx) return;
    int mid=(lx+rx)/2;
    for (int i=lx; i<=mid; i++)
    {
        S[i]='1';
        add_element(S);
        S[i]='0';
    }
    for (int i=lx; i<=mid; i++) S[i]='1';
    build(mid+1,rx);
    for (int i=lx; i<=mid; i++) S[i]='0';
    for (int i=mid+1; i<=rx; i++) S[i]='1';
    build(lx,mid);
    for (int i=mid+1; i<=rx; i++) S[i]='0';
}
void dnc(int lx, int rx, vector <int> tmp)
{
    if (lx==rx)
    {
        res[tmp[0]] = lx;
        return;
    }
    int mid=(lx+rx)/2;
    vector <int> ll,rr;
    for (int i=lx; i<=rx; i++)
    {
        S[tmp[i-lx]]='1';
        bool dau = check_element(S);
        if (dau) ll.push_back(tmp[i-lx]);
        else rr.push_back(tmp[i-lx]);
        S[tmp[i-lx]]='0';
    }
    for (int i:ll) S[i]='1';
    dnc(mid+1,rx,rr);
    for (int i:ll) S[i]='0';
    for (int i:rr) S[i]='1';
    dnc(lx,mid,ll);
    for (int i:rr) S[i]='0';
}
vector<int32_t> restore_permutation(int32_t n, int32_t w, int32_t r) {
    S="";
    for (int i=0; i<n; i++) S+='0';
    build(0,n-1);
    compile_set();
    res.assign(n,0);
    vector <int> tmp;
    for (int i=0; i<n; i++) tmp.push_back(i);
    for (int i=0; i<n; i++) S[i] = '0';
    dnc(0,n-1,tmp);
    return res;
}

Compilation message

messy.cpp: In function 'void dnc(int, int, std::vector<int>)':
messy.cpp:44:20: error: expected unqualified-id before ',' token
   44 |     vector <int> ll,rr;
      |                    ^
messy.cpp:3:17: error: 'long long' specified with 'std::vector<int>'
    3 | #define ll long long
      |                 ^~~~
messy.cpp:44:18: note: in expansion of macro 'll'
   44 |     vector <int> ll,rr;
      |                  ^~
messy.cpp:49:20: error: expected unqualified-id before '.' token
   49 |         if (dau) ll.push_back(tmp[i-lx]);
      |                    ^
messy.cpp:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
messy.cpp:53:16: note: in expansion of macro 'll'
   53 |     for (int i:ll) S[i]='1';
      |                ^~
messy.cpp:53:16: error: expected ')' before 'long'
   53 |     for (int i:ll) S[i]='1';
      |         ~      ^
      |                )
messy.cpp:53:18: error: expected unqualified-id before ')' token
   53 |     for (int i:ll) S[i]='1';
      |                  ^
messy.cpp:53:14: warning: unused variable 'i' [-Wunused-variable]
   53 |     for (int i:ll) S[i]='1';
      |              ^
messy.cpp:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
messy.cpp:55:16: note: in expansion of macro 'll'
   55 |     for (int i:ll) S[i]='0';
      |                ^~
messy.cpp:55:16: error: expected ')' before 'long'
   55 |     for (int i:ll) S[i]='0';
      |         ~      ^
      |                )
messy.cpp:55:18: error: expected unqualified-id before ')' token
   55 |     for (int i:ll) S[i]='0';
      |                  ^
messy.cpp:55:14: warning: unused variable 'i' [-Wunused-variable]
   55 |     for (int i:ll) S[i]='0';
      |              ^
messy.cpp:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
messy.cpp:57:16: note: in expansion of macro 'll'
   57 |     dnc(lx,mid,ll);
      |                ^~