Submission #940685

# Submission time Handle Problem Language Result Execution time Memory
940685 2024-03-07T13:20:45 Z velislavgarkov Super Dango Maker (JOI22_dango3) C++17
22 / 100
122 ms 988 KB
    #include "dango3.h"
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    const int MAXN=1e4+10;
    bool used[MAXN];
    vector <int> solve(vector <int> a, int n, int m) {
        if (a.size()==n) {
            Answer(a);
            return {};
        }
        if (m>1) {
            vector <int> q, s1;
            int l, r, mid, gr=m/2;
            l=gr*n-1; r=a.size()-1;
            while (l<r) {
                mid=(l+r)/2;
                if (!q.empty()) q.clear();
                for (int i=0;i<=mid;i++) q.push_back(a[i]);
                if (Query(q)<gr) l=mid+1;
                else r=mid;
            }
     
            for (int i=0;i<=l;i++) s1.push_back(a[i]);
            if (!q.empty()) q.clear(); 
            q=solve(s1,n,gr);
     
            s1.clear();
            for (int i=l+1;i<a.size();i++) s1.push_back(a[i]);
            for (auto i:q) s1.push_back(i);
            return solve(s1,n,m-gr);
        }
     
        vector <int> cur_ans, q;
        for (auto i:a) cur_ans.push_back(i);
     
        for (int i=0;i<a.size();i++) {
            if (cur_ans.size()==n) break;
            cur_ans.erase(cur_ans.begin());
            if (Query(cur_ans)==0) cur_ans.push_back(a[i]);
            else q.push_back(a[i]);
        }
        Answer(cur_ans);
        return q;
    }
    void Solve(int N, int M) {
        int n, m;
        n=N; m=M;
        vector <int> a;
        for (int i=1;i<=n*m;i++) a.push_back(i);
        random_shuffle(a.begin(),a.end());
        solve(a,n,m);
    }

Compilation message

dango3.cpp: In function 'std::vector<int> solve(std::vector<int>, int, int)':
dango3.cpp:9:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |         if (a.size()==n) {
      |             ~~~~~~~~^~~
dango3.cpp:30:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int i=l+1;i<a.size();i++) s1.push_back(a[i]);
      |                            ~^~~~~~~~~
dango3.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i=0;i<a.size();i++) {
      |                      ~^~~~~~~~~
dango3.cpp:39:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |             if (cur_ans.size()==n) break;
      |                 ~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 740 KB Output is correct
2 Correct 34 ms 740 KB Output is correct
3 Correct 31 ms 600 KB Output is correct
4 Correct 34 ms 604 KB Output is correct
5 Correct 29 ms 604 KB Output is correct
6 Correct 29 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 988 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -