#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include "grader.h"
using namespace std;
vector < vector < int > > all;
vector < int > con;
vector < int > how;
bool have[500]={0};
vector < int > tt;
int N,now=0,t;
int cmp(vector < int > a, vector < int > b)
{
int i;
int N=a.size(),con=0;
for(i=0;i<N;i++) if(a[i]==b[i]) con++;
return con;
}
bool F(int here)
{
int ok=1,i,j,xx;
//printf("%d\n",now);
if(here==N)
{
/*for(i=0;i<N;i++) printf("%d ",how[i]);
printf("\n");*/
//printf("qqqq\n");
for(i=0;i<now;i++)
{
//printf("qqq %d %d\n",tt[i],con[i]);
if(tt[i]!=con[i]) ok=0;
}
if(ok)
{
t=query(how);
//printf("%d\n",t);
all.push_back(how);
return 1;
}
return 0;
}
for(i=0;i<now;i++) if(tt[i]>con[i]) return 0;
for(i=1;i<=N;i++)
{
if(!have[i])
{
how[here]=i;
for(j=0;j<now;j++) if(all[j][here]==i) tt[j]++;
have[i]=1;
xx=F(here+1);
//printf("%d %d %d\n",here,i,now);
have[i]=0;
for(j=0;j<now;j++) if(all[j][here]==i) tt[j]--;
if(xx) return 1;
}
}
return 0;
}
void solve(int N)
{
::N=N;
how.clear();
all.clear();
con.clear();
tt.clear();
int i,x,ok=1;
now=0;
t=0;
for(i=0;i<N;i++) how.push_back(i+1);
while(t!=N)
{
//printf("aa\n");
for(i=0;i<N;i++) how[i]=i+1;
x=0;
for(auto i:all)
{
tt[x]=0;
x++;
}
F(0);
//printf("bbbbbb\n");
con.push_back(t);
tt.push_back(0);
now++;
//break;
}
}
Compilation message
mouse.cpp: In function 'void solve(int)':
mouse.cpp:71:13: warning: unused variable 'ok' [-Wunused-variable]
71 | int i,x,ok=1;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
2 |
Correct |
1 ms |
384 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 8 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
2 |
Correct |
1 ms |
384 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 8 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 5 |
7 |
Execution timed out |
3065 ms |
256 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
2 |
Correct |
1 ms |
384 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 7 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 8 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 5 |
7 |
Execution timed out |
3065 ms |
256 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |