답안 #869643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869643 2023-11-05T07:18:26 Z willychan Super Dango Maker (JOI22_dango3) C++17
100 / 100
756 ms 880 KB
#include "dango3.h"

#include <vector>
#include<random>
#include<algorithm>
#include<iostream>
#include<cassert>
using namespace std;
namespace {

int variable_example = 1;
int n,m;
}  // namespace

void process(vector<int> &get,vector<int> &pos) {
    int k = pos.size();
    random_shuffle(pos.begin(),pos.end());
    vector<int> a;
    for(int i=1; i<k; i++) a.push_back(pos[i]);
    vector<bool> notin(k,0);
    notin[0]=1;
    int should = (k/n)-1;
	int cnt = 1;
    for(int i=1; i<k; i++) {
		if(cnt==n) break;
        notin[i]=1;
        vector<int> q;
        for(int i=0; i<k; i++) if(!notin[i]) q.push_back(pos[i]);
        int g = Query(q);
        if(g!=should) notin[i]=0;
		else{
			cnt++;	
		}
    }
    for(int i=0; i<k; i++) if(notin[i]) get.push_back(pos[i]);
}
void Solve(int N, int M) {
    n = N;
    m = M;
    vector<int> pos(N*M);
    vector<bool> in(N*M+1);
    for(int i=0; i<N*M; i++) pos[i] = i+1;
    for(int i=0; i<M-1; i++) {
        vector<int> get;
        process(get,pos);
        for(auto i : get) in[i]=1;
        assert(get.size()==n);
        Answer(get);
        vector<int> temp;
        for(auto i : pos) if(!in[i]) temp.push_back(i);
        swap(pos,temp);
    }
    Answer(pos);
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from dango3.cpp:7:
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:47:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         assert(get.size()==n);
      |                ~~~~~~~~~~^~~
dango3.cpp: At global scope:
dango3.cpp:11:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   11 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 7 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 644 KB Output is correct
2 Correct 189 ms 648 KB Output is correct
3 Correct 159 ms 660 KB Output is correct
4 Correct 161 ms 660 KB Output is correct
5 Correct 155 ms 604 KB Output is correct
6 Correct 158 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 749 ms 776 KB Output is correct
2 Correct 716 ms 816 KB Output is correct
3 Correct 704 ms 784 KB Output is correct
4 Correct 756 ms 880 KB Output is correct
5 Correct 723 ms 784 KB Output is correct
6 Correct 745 ms 784 KB Output is correct