답안 #937850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937850 2024-03-04T15:24:52 Z velislavgarkov Super Dango Maker (JOI22_dango3) C++17
22 / 100
98 ms 1864 KB
#include "dango3.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN=1e4+10;
bool used[MAXN];
void solve(vector <int> a, int n) {
    if (a.size()==n) {
        Answer(a);
        return;
    }
    vector <int> q, cur_ans;
    int l, r, mid;
    l=0; 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)==0) l=mid+1;
        else r=mid;
    }
    int ind=l, gr=0;
    cur_ans.push_back(a[ind]);
    for (int j=1;j<n;j++) {
        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]);
        gr=l+1;
    }
    for (int i=0;i<n;i++) used[cur_ans[i]]=true;
    vector <int> newa;
    for (int i=0;i<a.size();i++) {
        if (!used[a[i]]) newa.push_back(a[i]);
    }
    Answer(cur_ans);
    solve(newa,n);
}
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);
}

Compilation message

dango3.cpp: In function 'void solve(std::vector<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:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1116 KB Output is correct
2 Correct 31 ms 1116 KB Output is correct
3 Correct 32 ms 1116 KB Output is correct
4 Correct 30 ms 1116 KB Output is correct
5 Correct 31 ms 1180 KB Output is correct
6 Correct 30 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 98 ms 1864 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -