답안 #956023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956023 2024-03-31T19:53:23 Z MarwenElarbi Super Dango Maker (JOI22_dango3) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#include "dango3.h"
using namespace std;
namespace {

    using std::exit;
    using std::fprintf;
    using std::printf;
    using std::scanf;

    constexpr int Q_MAX = 50'000;
    constexpr int NM_MAX = 10'000;

    int N;
    int M;
    int C[NM_MAX + 1];

    int query_count = 0;
    int answer_count = 0;
    bool finishes[NM_MAX + 1];

    void WrongAnswer(int code) {
      printf("Wrong Answer [%d]\n", code);
      exit(0);
    }
}  // namespace

int Query(const std::vector<int> &x) {
    if (++query_count > Q_MAX) WrongAnswer(3);
    bool presents[NM_MAX + 1];
    for (int i = 1; i <= N * M; ++i) presents[i] = false;
    int colors[NM_MAX + 1];
    for (int i = 1; i <= N; i++) colors[i] = 0;
    for (const int t : x) {
        if (t <= 0 || t > N * M) WrongAnswer(1);
        if (presents[t]) WrongAnswer(2);
        presents[t] = true;
        colors[C[t]]++;
    }
    int color_min = M;
    for (int i = 1; i <= N; i++) {
        if (colors[i] < color_min) color_min = colors[i];
    }
    return color_min;
}

void Answer(const std::vector<int> &a) {
  ++answer_count;
  if ((int)a.size() != N) WrongAnswer(4);
  for (const int t : a) {
    if (t <= 0 || t > N * M) WrongAnswer(5);
    if (finishes[t]) WrongAnswer(6);
    finishes[t] = true;
  }
  int colors[NM_MAX + 1];
  for (int i = 1; i <= N; i++) colors[i] = 0;
  for (const int t : a) {
    colors[C[t]]++;
  }
  for (int i = 1; i <= N; i++) {
    if (colors[i] != 1) WrongAnswer(7);
  }
}
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]);
    }
}

/*int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
  if (scanf("%d%d", &N, &M) != 2) {
    fprintf(stderr, "Error while reading input.\n");
    exit(1);
  }
  for (int i = 1; i <= N * M; ++i) {
    if (scanf("%d", &C[i]) != 1) {
      fprintf(stderr, "Error while reading input.\n");
      exit(1);
    }
  }
  for (int i = 1; i <= N * M; ++i) finishes[i] = false;
  Solve(N, M);
  if (answer_count != M) WrongAnswer(8);
  printf("Accepted: %d\n", query_count);
  return 0;
}*/

Compilation message

/usr/bin/ld: /tmp/cc52qiXc.o: in function `Query(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x50): multiple definition of `Query(std::vector<int, std::allocator<int> > const&)'; /tmp/cc1yi2Md.o:dango3.cpp:(.text+0x280): first defined here
/usr/bin/ld: /tmp/cc52qiXc.o: in function `Answer(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x1c0): multiple definition of `Answer(std::vector<int, std::allocator<int> > const&)'; /tmp/cc1yi2Md.o:dango3.cpp:(.text+0x2b0): first defined here
collect2: error: ld returned 1 exit status