답안 #555779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
555779 2022-05-01T14:11:17 Z Koosha_mv Super Dango Maker (JOI22_dango3) C++17
100 / 100
746 ms 844 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "dango3.h"

const int N=500;

int n,m,a[N],cnt[N],mark[N];
/*
void Answer(vector<int> vec){
	cout<<"ANS "; for(auto x : vec) cout<<x<<" ",mark[a[x]]++; cout<<endl;
	f(i,1,n){
		if(mark[i]!=mark[i+1]){
			cout<<"Wrong Answer 1";
			exit(0);
		}
	}
}
int Query(vector<int> vec){
	fill(cnt,cnt+N,0);
	f(i,0,vec.size()) cnt[a[vec[i]]]++;
	int ans=N;
	f(i,1,n+1) minm(ans,cnt[i]);
	dbgv(vec);
	cout<<"Qans "<<ans<<endl;
	return ans;
}
*/
void solve(vector<int> vec){
	if(vec.size()==n){
		Answer(vec);
		return ;
	}
	int m=vec.size()/n;
	vector<int> vec0,vec1;
	f_(i,vec.size()-1,0){
		vector<int> pec=vec;
		pec.erase(pec.begin()+i);
		if(2*Query(pec)>=m){
			vec0.pb(vec[i]);
			vec=pec;
		}
		else{
			vec1.pb(vec[i]);
		}
	}
	solve(vec0);
	solve(vec1);
}
void Solve(int _n, int _m){
	n=_n,m=_m;
	vector<int> vec(n*m);
	iota(all(vec),1);
	solve(vec);	
}
/*
int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>m;
	f(i,1,n*m+1) cin>>a[i];
	Solve(n,m);
}
*/

Compilation message

dango3.cpp: In function 'void solve(std::vector<int>)':
dango3.cpp:48:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |  if(vec.size()==n){
      |     ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 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 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 340 KB Output is correct
2 Correct 9 ms 340 KB Output is correct
3 Correct 9 ms 380 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 8 ms 308 KB Output is correct
6 Correct 8 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 504 KB Output is correct
2 Correct 163 ms 600 KB Output is correct
3 Correct 211 ms 516 KB Output is correct
4 Correct 218 ms 516 KB Output is correct
5 Correct 139 ms 508 KB Output is correct
6 Correct 167 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 646 ms 728 KB Output is correct
2 Correct 710 ms 636 KB Output is correct
3 Correct 746 ms 740 KB Output is correct
4 Correct 720 ms 648 KB Output is correct
5 Correct 676 ms 632 KB Output is correct
6 Correct 720 ms 844 KB Output is correct