답안 #1077870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077870 2024-08-27T09:57:43 Z 0npata Super Dango Maker (JOI22_dango3) C++17
22 / 100
262 ms 1112 KB
#include "dango3.h"
#include<bits/stdc++.h>
using namespace std;

#define vec vector

const int MXSZ = 400*25;

vec<int> ri_to;
vec<int> ri_from;

int query(vec<int> v) {
    for(int i = 0; i<v.size(); i++) {
        v[i] = ri_to[v[i]]+1;
        //cerr << v[i] << ' ';
    }
    //cerr << '\n';
    return Query(v);
}

void Solve(int N, int M) {
    srand(200);

    ri_to = vec<int>(N*M);
    iota(ri_to.begin(), ri_to.end(), 0);
    random_shuffle(ri_to.begin(), ri_to.end());



    vec<vec<int>> cols_inds{};
    vec<int> rem(N*M);
    iota(rem.begin(), rem.end(), 0);

    while(cols_inds.size() < N) {
        //cerr << "NEW ONE" << '\n';
        vec<int> v{};
        for(auto cis : cols_inds) {
            v.push_back(cis[0]);
        }
        int l = 0;
        int r = rem.size();
        while(l<r) {
            int m = (l+r)/2;
            vec<int> qv = v;
            for(int i = 0; i<=m; i++) {
                qv.push_back(rem[i]);
            }
            //cerr << '\n';
            int res = query(qv);
            if(res >= 1) {
                r = m;
            }
            else {
                l = m+1;
            }
        }
        vec<int> col_inds{rem[l]};
        for(int i = 0; i<l; i++) v.push_back(rem[i]);
        // now v contains everything at least once except the col
        // therefore the first one will always correspond to the same col
        while(col_inds.size() < M) {
            //cerr << "HERE" << '\n';
            l++;
            int last = l;
            int r = rem.size();
            while(l<r) {
                int m = (l+r)/2;
                auto qv = v;
                for(int i = last; i<=m; i++) {
                    qv.push_back(rem[i]);
                }
                int res = query(qv);
                if(res >= 1) {
                    r = m;
                }
                else {
                    l = m+1;
                }
            }
            col_inds.push_back(rem[l]);
        }
        assert(col_inds.size() == M);
        cols_inds.push_back(col_inds);
        set<int> nrem(rem.begin(), rem.end());
        for(int ind : col_inds) {
            //cerr << ind << ' ';
            nrem.erase(ind);
        }
        //cerr << '\n';
        rem = vec<int>(nrem.begin(), nrem.end());
    }

    for(int i = 0; i<M; i++) {
        vec<int> ans(N);
        for(int j = 0; j<N; j++) {
            ans[j] = ri_to[cols_inds[j][i]]+1;
        }

        Answer(ans); 
    }
}

Compilation message

dango3.cpp: In function 'int query(std::vector<int>)':
dango3.cpp:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i<v.size(); i++) {
      |                    ~^~~~~~~~~
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:34:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while(cols_inds.size() < N) {
      |           ~~~~~~~~~~~~~~~~~^~~
dango3.cpp:61:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         while(col_inds.size() < M) {
      |               ~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dango3.cpp:2:
dango3.cpp:82:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |         assert(col_inds.size() == M);
      |                ~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 348 KB Output is correct
2 Correct 9 ms 580 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 9 ms 348 KB Output is correct
5 Correct 9 ms 584 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 600 KB Output is correct
2 Correct 101 ms 836 KB Output is correct
3 Correct 104 ms 600 KB Output is correct
4 Correct 100 ms 604 KB Output is correct
5 Correct 111 ms 604 KB Output is correct
6 Correct 101 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 262 ms 1112 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -