//Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI=acos(-1);
template<typename T> T getint() {
T val=0;
char c;
bool neg=false;
while((c=gc()) && !(c>='0' && c<='9')) {
neg|=c=='-';
}
do {
val=(val*10)+c-'0';
} while((c=gc()) && (c>='0' && c<='9'));
return val*(neg?-1:1);
}
map<vector<int>, int> dp;
int ask(vector<int> H) {
sort(all(H));
if(dp.find(H)!=dp.end()) {
return dp[H];
}
if(sz(H)==1) return 1;
cout<<"1 ";
for(auto i:H) {
cout<<i<<" ";
}cout<<"\n";
fflush(stdout);
int resp;
cin>>resp;
return dp[H]=resp;
}
vector<int> cut(vector<int> H, int l, int r) {
vector<int> res(r-l+1);
copy(H.begin()+l, H.begin()+r+1, res.begin());
return res;
}
vector<int> next_group(vector<int> H) {
vector<int> ans;
while(sz(H)>1) {
if(ask(cut(H, 0, sz(H)-1))==ask(cut(H, 1, sz(H)-1))) //van még egy ugyanilyen
{
int akt=sz(H)-1;
for(int i=10;i>=0;i--) {
int curr=akt-(1<<i);
if(curr>0 && ask(cut(H, 0, curr))==ask(cut(H, 1, curr))) {
akt=curr;
}
}
assert(ask({H[0], H[akt]})==1);
ans.pb(H[0]);
int atBegin=H[akt];
while(H[0]!=atBegin) {
H.erase(H.begin());
}
}else {
break ;
}
}
ans.pb(H[0]);
return ans;
}
int main() {
IO;
int n;
cin>>n;
vector<int> H;
for(int i=1;i<=n;++i) H.pb(i);
vector<int> ans(n);
for(int id=1;sz(H)>0;id++) {
vector<int> curr_group=next_group(H);
for(auto i:curr_group) {
ans[i-1]=id;
}
for(auto i=H.begin();i!=H.end();i++) {
auto it=find(all(curr_group), *i);
if(it!=curr_group.end() && *it==*i) {
i=H.erase(i);
if(i==H.end()) break ;
}
}
}
cout<<"0";
for(auto i:ans) cout<<" "<<i;
cout<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
248 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
308 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
392 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2 ms |
448 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |