답안 #546198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546198 2022-04-06T15:56:28 Z leaked Super Dango Maker (JOI22_dango3) C++17
100 / 100
3978 ms 724 KB
#include "dango3.h"

#include <vector>
#include <bits/stdc++.h>

#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define m_p make_pair
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const int N=1e5+1;
const ll inf=1e18;
namespace {

int variable_example = 1;

}  // namespace

void Solve(int n, int m) {
//    ::n=n;::m=m;
//    vec<int> dif;
    vec<vec<int>> who(m,vec<int>());
    vec<bool>used(n*m+1,0);
    auto ask=[&](vec<int> ids,int x){
        vec<int> wt;

        for(auto &i : ids){
            for(auto &j : who[i]){
                used[j]=1;
            }
        }
        used[x]=1;

        for(int i=1;i<=n*m;i++){
            if(!used[i]) wt.pb(i);
        }

        for(auto &i : ids){
            for(auto &j : who[i]){
                used[j]=0;
            }
        }
        used[x]=0;

        return Query(wt);
//        vec<boo
    };
    vec<int> ids;
    for(int i=1;i<=n*m;i++) ids.pb(i);
    for(int i=1;i<=n*m;i++){
        vec<int> me;
        for(int j=0;j<m;j++){
            if(sz(who[j])!=n) me.pb(j);
        }
        vec<int> cand=me;
        while(sz(cand)!=1){
            vec<int> lft,rgt;
            for(int j=0;j<(sz(cand)+1)/2;j++) lft.pb(cand[j]);
            for(int j=sz(lft);j<sz(cand);j++) rgt.pb(cand[j]);
            if(ask(lft,i)==(m-sz(lft)-1)) cand=rgt;
            else cand=lft;
        }
        who[cand[0]].pb(i);
    }
    for(int j=0;j<m;j++){
//        vec<int> wow;
//        for(int i=0;i<n;i++)
//            wow.pb(who[i][j]);
        Answer(who[j]);
    }
}
/*
3 2
3 3 1 2 1 2
4 4
2 2 3 2 4 4 3 2 3 1 1 3 4 1 4 1

*/

Compilation message

dango3.cpp:26:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   26 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 340 KB Output is correct
2 Correct 30 ms 352 KB Output is correct
3 Correct 32 ms 360 KB Output is correct
4 Correct 33 ms 364 KB Output is correct
5 Correct 26 ms 372 KB Output is correct
6 Correct 26 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 912 ms 444 KB Output is correct
2 Correct 917 ms 572 KB Output is correct
3 Correct 1039 ms 708 KB Output is correct
4 Correct 1034 ms 448 KB Output is correct
5 Correct 845 ms 580 KB Output is correct
6 Correct 851 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3404 ms 552 KB Output is correct
2 Correct 3538 ms 608 KB Output is correct
3 Correct 3978 ms 564 KB Output is correct
4 Correct 3961 ms 724 KB Output is correct
5 Correct 3211 ms 572 KB Output is correct
6 Correct 3194 ms 576 KB Output is correct