답안 #956022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956022 2024-03-31T19:52:51 Z MarwenElarbi Super Dango Maker (JOI22_dango3) C++17
컴파일 오류
0 ms 0 KB
#include <vector>

#include "dango3.h"

int Query(const std::vector<int> &x);
void Answer(const std::vector<int> &a);
set<int> colors[25];
void Solve(int N, int M){
    int n=N;
    int m=M;
    //cout <<n<<" "<<m<<endl;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            int l=-1;
            int r=m-1;
            while(r-l>1){
                int mid=(r+l)/2;
                vector<int> cur;
                for (int k = 1; k <= n*m; ++k)
                {
                    if(k==i*m+j+1) continue;
                    if(colors[mid].count(k)) continue;
                    cur.push_back(k); 
                }
                int res=Query(cur);
                if(m-res>1) l=mid;
                else r=mid;
            }
            //for(auto u:colors[0]) cout <<u<<" ";
            //cout <<endl;
            vector<int> cur;
            for (int k = 1; k <= n*m; ++k)
            {
                if(k==i*m+j+1) continue;
                if(colors[r].count(k)) continue;
                cur.push_back(k); 
            }
            //cout <<r<<" "<<Query(cur)<<" "<<i*m+j+1<<" "<<i<<" "<<j<<endl;
            colors[r].insert(i*m+j+1);
        }
    }
    vector<int> ans[m];
    for (int i = 0; i < m; ++i)
    {
        //cout <<colors[i].size()<<endl;
        for(auto u:colors[i]) ans[i].push_back(u); 
    }
    for (int i = 0; i < m; ++i)
    {
        Answer(ans[i]);
    }
}

Compilation message

dango3.cpp:7:1: error: 'set' does not name a type
    7 | set<int> colors[25];
      | ^~~
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:20:17: error: 'vector' was not declared in this scope
   20 |                 vector<int> cur;
      |                 ^~~~~~
dango3.cpp:20:17: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from dango3.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from dango3.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dango3.cpp:20:24: error: expected primary-expression before 'int'
   20 |                 vector<int> cur;
      |                        ^~~
dango3.cpp:24:24: error: 'colors' was not declared in this scope
   24 |                     if(colors[mid].count(k)) continue;
      |                        ^~~~~~
dango3.cpp:25:21: error: 'cur' was not declared in this scope
   25 |                     cur.push_back(k);
      |                     ^~~
dango3.cpp:27:31: error: 'cur' was not declared in this scope
   27 |                 int res=Query(cur);
      |                               ^~~
dango3.cpp:33:13: error: 'vector' was not declared in this scope
   33 |             vector<int> cur;
      |             ^~~~~~
dango3.cpp:33:13: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from dango3.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from dango3.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dango3.cpp:33:20: error: expected primary-expression before 'int'
   33 |             vector<int> cur;
      |                    ^~~
dango3.cpp:37:20: error: 'colors' was not declared in this scope
   37 |                 if(colors[r].count(k)) continue;
      |                    ^~~~~~
dango3.cpp:38:17: error: 'cur' was not declared in this scope
   38 |                 cur.push_back(k);
      |                 ^~~
dango3.cpp:41:13: error: 'colors' was not declared in this scope
   41 |             colors[r].insert(i*m+j+1);
      |             ^~~~~~
dango3.cpp:44:5: error: 'vector' was not declared in this scope
   44 |     vector<int> ans[m];
      |     ^~~~~~
dango3.cpp:44:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from dango3.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from dango3.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dango3.cpp:44:12: error: expected primary-expression before 'int'
   44 |     vector<int> ans[m];
      |            ^~~
dango3.cpp:48:20: error: 'colors' was not declared in this scope
   48 |         for(auto u:colors[i]) ans[i].push_back(u);
      |                    ^~~~~~
dango3.cpp:48:31: error: 'ans' was not declared in this scope
   48 |         for(auto u:colors[i]) ans[i].push_back(u);
      |                               ^~~
dango3.cpp:52:16: error: 'ans' was not declared in this scope
   52 |         Answer(ans[i]);
      |                ^~~