Submission #900652

# Submission time Handle Problem Language Result Execution time Memory
900652 2024-01-08T19:32:51 Z alexander707070 Super Dango Maker (JOI22_dango3) C++17
100 / 100
671 ms 1152 KB
#include<bits/stdc++.h>
#include "dango3.h"
using namespace std;

int n,m;

int li[10007],tim;
vector<int> v;

void solve(vector<int> el){

    if(el.size()==n){
        Answer(el); return;
    }

    int half=(el.size()/n)/2;
    vector<int> curr,rest;
    deque<int> d;

    int l=half*n,r=el.size(),mid;

    while(l+1<r){
        mid=(l+r)/2;

        curr.clear();
        for(int p=0;p<mid;p++){
            curr.push_back(el[p]);
        }

        if(Query(curr)>=half){
            r=mid;
        }else{
            l=mid;
        }
    }
    
    curr.clear();
    for(int i=0;i<r;i++)curr.push_back(el[i]);

    for(int i:curr)d.push_back(i);

    int sz=curr.size(),rem=0;
    for(int i=0;i<sz;i++){
        rem=d.back();
        d.pop_back();

        curr={};
        for(int f=0;f<d.size();f++){
            curr.push_back(d[f]);
        }

        if(Query(curr)==half)continue;
        else d.push_front(rem);

        if(int(d.size())==half*n)break;
    }

    tim++; curr.clear();
    for(int i=0;i<d.size();i++){
        curr.push_back(d[i]);
        li[d[i]]=tim;
    }

    for(int i=0;i<el.size();i++){
        if(li[el[i]]!=tim){
            rest.push_back(el[i]);
        }
    }
    
    solve(curr);
    solve(rest);
}

void Solve(int N, int M){
    n=N; m=M;

    for(int i=1;i<=n*m;i++){
        v.push_back(i);
    }

    solve(v);
}

Compilation message

dango3.cpp: In function 'void solve(std::vector<int>)':
dango3.cpp:12:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     if(el.size()==n){
      |        ~~~~~~~~~^~~
dango3.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(int f=0;f<d.size();f++){
      |                     ~^~~~~~~~~
dango3.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<d.size();i++){
      |                 ~^~~~~~~~~
dango3.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<el.size();i++){
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 4 ms 536 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 6 ms 524 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 632 KB Output is correct
2 Correct 79 ms 680 KB Output is correct
3 Correct 161 ms 600 KB Output is correct
4 Correct 166 ms 1120 KB Output is correct
5 Correct 15 ms 600 KB Output is correct
6 Correct 15 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 339 ms 856 KB Output is correct
2 Correct 339 ms 1104 KB Output is correct
3 Correct 671 ms 1152 KB Output is correct
4 Correct 657 ms 1104 KB Output is correct
5 Correct 69 ms 848 KB Output is correct
6 Correct 49 ms 868 KB Output is correct