답안 #596837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596837 2022-07-15T07:24:22 Z 조영욱(#8449) Super Dango Maker (JOI22_dango3) C++17
7 / 100
3996 ms 732 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;
        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);
                }
            }
            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()) {
                        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:53:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                 for(int j=0;j<v.size();j++) {
      |                             ~^~~~~~~~~
dango3.cpp: At global scope:
dango3.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 368 KB Output is correct
2 Correct 151 ms 368 KB Output is correct
3 Correct 20 ms 380 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 149 ms 372 KB Output is correct
6 Correct 138 ms 368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2035 ms 476 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3996 ms 732 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -