Submission #596885

# Submission time Handle Problem Language Result Execution time Memory
596885 2022-07-15T08:43:10 Z 조영욱(#8449) Super Dango Maker (JOI22_dango3) C++17
7 / 100
3973 ms 676 KB
#include "dango3.h"

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

namespace {

int variable_example = 1;
bool chk[100001];
int ret[100001];
bool used[401];
}  // namespace

void Solve(int n,int m) {
    for(int i=1;i<=n;i++) {
        int cnt=1;
        int st=0;
        if (i==n){
            for(int j=1;j<=n*m;j++) {
                if (!chk[j]) {
                    ret[j]=i;
                }
            }
            break;
        }
        for(int j=1;j<=n*m;j++) {
            if (!chk[j]) {
                chk[j]=true;
                st=j;
                ret[j]=i;
                break;
            }
        }
        int ind=st+1;
        while (ind<=n*m) {
            if (cnt==m) {
                break;
            }
            vector<int> vec;
            int le=ind;
            int ri=ind-1;
            int val=0;
            vector<int> v;
            while (ri+1<=n*m&&val<cnt) {
                if (!chk[ri+1]) {
                    val++;
                    v.push_back(ri+1);
                }
                ri++;
            }
            for(int j=1;j<=n*m;j++) {
                if (j<le||j>ri) {
                    if (ret[j]!=i)
                        vec.push_back(j);
                }
                else if (chk[j]) {
                    vec.push_back(j);
                }
            }
            int got=Query(vec);
            //printf("%d %d %d %d %d\n",i,ind,got,le,ri);
            if (got<m-cnt) {
                int found=m-cnt-got;
                for(int j=0;j<v.size();j++) {
                    if (found==0) {
                        break;
                    }
                    int now=v[j];
                    if (j+1==v.size()) {
                        assert(found==1);
                        cnt++;
                        found--;
                        chk[now]=true;
                        ret[now]=i;
                        break;
                    }
                    vector<int> vec;
                    for(int k=1;k<=n*m;k++) {
                        if(k!=st&&k!=now) {
                            vec.push_back(k);
                        }
                    }
                    //printf("%d %d %d\n",i,le,ri);
                    if (Query(vec)<m-1) {
                        cnt++;
                        found--;
                        chk[now]=true;
                        ret[now]=i;
                    }
                }
            }
            ind=ri+1;
        }
    }
    memset(chk,0,sizeof(chk));
    for(int i=1;i<=m;i++) {
        memset(used,0,sizeof(used));
        vector<int> vec;
        for(int j=1;j<=n*m;j++) {
            //printf("%d ",ret[j]);
            if (!chk[j]&&!used[ret[j]]) {
                used[ret[j]]=true;
                chk[j]=true;
                vec.push_back(j);
            }
        }
        //printf("\n");
        Answer(vec);
    }
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:64:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |                 for(int j=0;j<v.size();j++) {
      |                             ~^~~~~~~~~
dango3.cpp:69:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |                     if (j+1==v.size()) {
      |                         ~~~^~~~~~~~~~
dango3.cpp: At global scope:
dango3.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 360 KB Output is correct
2 Correct 105 ms 364 KB Output is correct
3 Correct 15 ms 468 KB Output is correct
4 Correct 19 ms 468 KB Output is correct
5 Correct 101 ms 384 KB Output is correct
6 Correct 148 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2000 ms 472 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3973 ms 676 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -