#include "chameleon.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int n;
int vis[2010];
int love[2010];
vector<int>e[2010];
int lvlv[2010];
int slv(int a,vector<int>vc){
if(Query({a,vc[0],vc[1]})==1){
return vc[2];
}
if(Query({a,vc[0],vc[2]})==1){
return vc[1];
}
return vc[0];
}
int ask(int l,int r,vector<int>&vc){
for(int i=l;i<=r;i++){
vc.push_back(i);
}
return Query(vc);
}
int ans[2010];
int dgr[2010];
void slvv(){
for(int i=1;i<=n;i++){
if(e[i].size()==1){
lvlv[i]=1;
dgr[e[i][0]]++;
}
}
for(int i=1;i<=n;i++){
if(dgr[n+i]==1){
lvlv[n+i]=1;
}
}
}
void Solve(int N) {
n=N;
if(n<=50){
for(int i=1;i<=n*2;i++){
for(int j=i+1;j<=n*2;j++){
if(Query({i,j})==1){
e[i].push_back(j);
e[j].push_back(i);
}
}
}
}else{
for(int i=1;i<=n;i++){
int l;int r;
l=n+1;r=n*2+1;
while(l<r){
int mi=l+(r-l)/2;
vector<int>vc;
vc={i};
if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
r=mi;
}else{
l=mi+1;
}
}
e[i].push_back(l);
l++;r=n*2+1;
while(l<r){
int mi=l+(r-l)/2;
vector<int>vc;
vc={i};
if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
r=mi;
}else{
l=mi+1;
}
}
e[i].push_back(l);
l++;r=n*2+1;
while(l<r){
int mi=l+(r-l)/2;
vector<int>vc;
vc={i};
if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
r=mi;
}else{
l=mi+1;
}
}
e[i].push_back(l);
while(e[i].back()>=n*2+1){
e[i].pop_back();
}
}
for(int i=1;i<=n;i++){
for(auto v:e[i]){
e[v].push_back(i);
}
}
}
for(int i=1;i<=n*2;i++){
if(e[i].size()==1){
ans[i]=e[i][0];
lvlv[i]=1;
}
}
for(int i=1;i<=n*2;i++){
if(e[i].size()==3){
love[i]=slv(i,e[i]);
}
}
for(int i=1;i<=n*2;i++){
if(e[i].size()==1){continue;}
if(e[i].size()!=3){
exit(e[i].size());
}
if(e[i][0]!=love[i]&&(love[e[i][0]]!=i||lvlv[e[i][0]])){ans[i]=e[i][0];}
if(e[i][1]!=love[i]&&(love[e[i][1]]!=i||lvlv[e[i][1]])){ans[i]=e[i][1];}
if(e[i][2]!=love[i]&&(love[e[i][2]]!=i||lvlv[e[i][2]])){ans[i]=e[i][2];}
}
for(int i=1;i<=n*2;i++){
if(ans[i]<i){
Answer(i,ans[i]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Runtime error |
19 ms |
516 KB |
Execution failed because the return code was nonzero |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
344 KB |
Output is correct |
18 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
33 ms |
344 KB |
Line [name=secret] equals to "", doesn't correspond to pattern "[A-Za-z0-9]{1,100}" |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Runtime error |
19 ms |
516 KB |
Execution failed because the return code was nonzero |
4 |
Halted |
0 ms |
0 KB |
- |