제출 #1334409

#제출 시각아이디문제언어결과실행 시간메모리
1334409kenkunkinLibrary (JOI18_library)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "library.h"

using namespace std;
int sum=0;
void Solve(int N)
{
    n=N;
    b.resize(n);
    for (int i=0;i<n;i++)    b[i]=0;
    for (int i=0;i<n;i++)
    {
        b[i]=1;
        int sum2=Query(b);
        if (sum2-sum==1)
        {
            g[++m].push_back(i);
        }
        else if (sum2-sum==0)
        {
            int id=xuly(i,1,m);
            int l=g[id][0],r=g[id].back();
            vector <int> v(n);
            for (int j=0;j<n;j++)   v[j]=0;
            v[r]=1,v[i]=1;
            if (Query(v)>1)
                flip(g[id]);
            g[id].push_back(i);
        }
        else
        {
            int lo=1,hi=m,x,y;
            while (lo<=hi)
            {
                int mi=(lo+hi)/2;
                int bien=check(lo,mi,i);
                if (bien==-1)    hi=mi-1;
                else if (bien==1)   lo=mi+1;
                else
                {
                    x=xuly(i,lo,mi);
                    y=xuly(i,mi+1,hi);
                    break;
                }
            }

            vector <int> v(n);
            for (int j=0;j<n;j++)   v[j]=0;
            v[i]=1,v[g[x].back()]=1;
            if (Query(v)>1)
                flip(g[x]);
            g[x].push_back(i);
            for (int j=0;j<n;j++)   v[j]=0;
            v[i]=1,v[g[y][0]]=1;
            if (Query(v)>1)
                flip(g[y]);
            for (int j=0;j<g[y].size();j++)
                g[x].push_back(g[y][j]);
            g[y].clear();

        }
        sum=sum2;
    }
    for (int i=1;i<=m;i++)
        if (!g[i].empty())
        {
            for (int j=0;j<g[i].size();j++)
                g[i][j]++;
            Answer(g[i]);
            return;
        }
}

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

library.cpp: In function 'void Solve(int)':
library.cpp:8:5: error: 'n' was not declared in this scope
    8 |     n=N;
      |     ^
library.cpp:9:5: error: 'b' was not declared in this scope
    9 |     b.resize(n);
      |     ^
library.cpp:17:13: error: 'g' was not declared in this scope
   17 |             g[++m].push_back(i);
      |             ^
library.cpp:17:17: error: 'm' was not declared in this scope
   17 |             g[++m].push_back(i);
      |                 ^
library.cpp:21:29: error: 'm' was not declared in this scope
   21 |             int id=xuly(i,1,m);
      |                             ^
library.cpp:21:20: error: 'xuly' was not declared in this scope
   21 |             int id=xuly(i,1,m);
      |                    ^~~~
library.cpp:22:19: error: 'g' was not declared in this scope
   22 |             int l=g[id][0],r=g[id].back();
      |                   ^
library.cpp:25:15: error: 'r' was not declared in this scope
   25 |             v[r]=1,v[i]=1;
      |               ^
library.cpp:27:17: error: 'flip' was not declared in this scope
   27 |                 flip(g[id]);
      |                 ^~~~
library.cpp:32:25: error: 'm' was not declared in this scope
   32 |             int lo=1,hi=m,x,y;
      |                         ^
library.cpp:36:26: error: 'check' was not declared in this scope
   36 |                 int bien=check(lo,mi,i);
      |                          ^~~~~
library.cpp:41:21: error: 'x' was not declared in this scope
   41 |                     x=xuly(i,lo,mi);
      |                     ^
library.cpp:41:23: error: 'xuly' was not declared in this scope
   41 |                     x=xuly(i,lo,mi);
      |                       ^~~~
library.cpp:42:21: error: 'y' was not declared in this scope
   42 |                     y=xuly(i,mi+1,hi);
      |                     ^
library.cpp:49:22: error: 'g' was not declared in this scope
   49 |             v[i]=1,v[g[x].back()]=1;
      |                      ^
library.cpp:49:24: error: 'x' was not declared in this scope
   49 |             v[i]=1,v[g[x].back()]=1;
      |                        ^
library.cpp:51:17: error: 'flip' was not declared in this scope
   51 |                 flip(g[x]);
      |                 ^~~~
library.cpp:54:24: error: 'y' was not declared in this scope
   54 |             v[i]=1,v[g[y][0]]=1;
      |                        ^
library.cpp:56:17: error: 'flip' was not declared in this scope
   56 |                 flip(g[y]);
      |                 ^~~~
library.cpp:64:21: error: 'm' was not declared in this scope
   64 |     for (int i=1;i<=m;i++)
      |                     ^
library.cpp:65:14: error: 'g' was not declared in this scope
   65 |         if (!g[i].empty())
      |              ^