Submission #783145

# Submission time Handle Problem Language Result Execution time Memory
783145 2023-07-14T15:59:12 Z JooDdae Super Dango Maker (JOI22_dango3) C++17
22 / 100
1257 ms 1060 KB
#include "dango3.h"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int m;

vector<int> done, imsi;
vector<int> type[404];

int query(vector<int> q) {
    for(auto x : done) q.push_back(x);
    for(auto x : imsi) q.push_back(x);
    return Query(q);
}

void find(int c, vector<int> v) {
    vector<vector<int>> u(1, v), x;

    int cnt = 0;
    while(type[c].size() + cnt < m) {
        cnt = 0;

        for(auto v : u) {
            int s = v.size();
            vector<int> v1 = vector<int>(v.begin(), v.begin()+s/2), v2 = vector<int>(v.begin()+s/2, v.end());

            int re = query(v1);

            if(re) {
                if(v1.size() == 1) type[c].push_back(v1[0]);
                else x.push_back(v1), cnt++;
            } else {
                for(auto x : v1) imsi.push_back(x);
            }

            if(type[c].size() == m) return;

            if(!re || query(v2)) {
                if(v2.size() == 1) type[c].push_back(v2[0]);
                else x.push_back(v2), cnt++;
            } else {
                for(auto x : v2) imsi.push_back(x);
            }

            if(type[c].size() == m) return;
        }

        swap(x, u), x.clear();
    }

    while(1) {

        for(auto v : u) {
            int s = v.size();
            vector<int> v1 = vector<int>(v.begin(), v.begin()+s/2), v2 = vector<int>(v.begin()+s/2, v.end());

            int re = query(v1);

            if(re) {
                if(v1.size() == 1) type[c].push_back(v1[0]);
                else x.push_back(v1);
            } else {
                if(v2.size() == 1) type[c].push_back(v2[0]);
                else x.push_back(v2);
            }

            if(type[c].size() == m) return;
        }

        swap(x, u), x.clear();
    }

    
}

void Solve(int N, int M) {
    m = M;

    vector<int> v(N*M);
    iota(v.begin(), v.end(), 1);

    random_device rd;
    shuffle(v.begin(), v.end(), mt19937(rd()));

    for(int i=0;i<N-1;i++) {
        find(i, v);

        for(auto x : type[i]) done.push_back(x);
        for(auto x : type[i]) v.erase(find(v.begin(), v.end(), x));
        imsi.clear();

        // for(auto x : v) cout << x << " ";
        // cout << i << " " << v.size();
        // cout << "DONE------------" << endl;
    }


    type[N-1] = v;

    for(int i=0;i<M;i++) {
        vector<int> re;
        for(int j=0;j<N;j++) {
            re.push_back(type[j][i]);
        }
        Answer(re);
    }
}

Compilation message

dango3.cpp: In function 'void find(int, std::vector<int>)':
dango3.cpp:22:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while(type[c].size() + cnt < m) {
      |           ~~~~~~~~~~~~~~~~~~~~~^~~
dango3.cpp:38:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |             if(type[c].size() == m) return;
      |                ~~~~~~~~~~~~~~~^~~~
dango3.cpp:47:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |             if(type[c].size() == m) return;
      |                ~~~~~~~~~~~~~~~^~~~
dango3.cpp:69:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |             if(type[c].size() == m) return;
      |                ~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 568 KB Output is correct
2 Correct 19 ms 524 KB Output is correct
3 Correct 19 ms 536 KB Output is correct
4 Correct 20 ms 724 KB Output is correct
5 Correct 19 ms 540 KB Output is correct
6 Correct 19 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 564 ms 824 KB Output is correct
2 Correct 553 ms 824 KB Output is correct
3 Correct 564 ms 820 KB Output is correct
4 Correct 555 ms 716 KB Output is correct
5 Correct 605 ms 828 KB Output is correct
6 Correct 579 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1257 ms 1060 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -