Submission #1077860

# Submission time Handle Problem Language Result Execution time Memory
1077860 2024-08-27T09:50:26 Z 0npata Super Dango Maker (JOI22_dango3) C++17
22 / 100
321 ms 1032 KB
#include "dango3.h"
#include<bits/stdc++.h>
using namespace std;

#define vec vector

const int MXSZ = 400*25;

int ri_to[MXSZ];
int ri_from[MXSZ];

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(69);
    for(int i = 0; i<N*M; i++) {
        ri_to[i] = i;
        ri_from[i] = i;
        //ri_to[i] = rand()%N;
        //ri_from[ri_to[i]] = i;
    }
    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_from[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:33:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while(cols_inds.size() < N) {
      |           ~~~~~~~~~~~~~~~~~^~~
dango3.cpp:60:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |         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:81:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   81 |         assert(col_inds.size() == M);
      |                ~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 600 KB Output is correct
2 Correct 9 ms 596 KB Output is correct
3 Correct 11 ms 344 KB Output is correct
4 Correct 11 ms 572 KB Output is correct
5 Correct 8 ms 344 KB Output is correct
6 Correct 8 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 860 KB Output is correct
2 Correct 108 ms 704 KB Output is correct
3 Correct 302 ms 856 KB Output is correct
4 Correct 321 ms 860 KB Output is correct
5 Correct 95 ms 856 KB Output is correct
6 Correct 99 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 1032 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -