Submission #940669

# Submission time Handle Problem Language Result Execution time Memory
940669 2024-03-07T13:01:39 Z velislavgarkov Super Dango Maker (JOI22_dango3) C++17
Compilation error
0 ms 0 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;
    int ind=a.size()-1, gr=0;
    cur_ans.push_back(a[ind]);
    for (int i=0;i<a.size();i++) used[i]=false;
    used[ind]=true;

    for (int j=1;j<n;j++) {
        int l, r, mid;
        l=gr; r=ind-1;
        while (l+1<r) {
            mid=(l+r)/2;
            if (!q.empty()) q.clear();
            for (int i=mid;i<ind;i++) q.push_back(a[i]);
            for (int i=0;i<j;i++) q.push_back(cur_ans[i]);
            if (Query(q)==0) r=mid;
            else l=mid;
        }
        cur_ans.push_back(a[l]);
        used[l]=true;
        gr=l+1;
    }
    if (query(cur_ans)==0) cout << 1/0 << endl;
    if (!q.empty()) q.clear();
    for (int i=0;i<a.size();i++) {
        if (!used[i]) 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:17: 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:25: 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:19: 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++) used[i]=false;
      |                  ~^~~~~~~~~
dango3.cpp:56:9: error: 'query' was not declared in this scope; did you mean 'Query'?
   56 |     if (query(cur_ans)==0) cout << 1/0 << endl;
      |         ^~~~~
      |         Query
dango3.cpp:56:37: warning: division by zero [-Wdiv-by-zero]
   56 |     if (query(cur_ans)==0) cout << 1/0 << endl;
      |                                    ~^~
dango3.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~