/*
ID: hedichehaidar
TASK: photo
LANG: C++11
*/
#include<bits/stdc++.h>
#include "library.h"
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vdd vector<pdd>
#define dte tuple<double , double , double>
using namespace std;
const int INF = 1000*1000*1000; // 1 e 9
const int MOD = INF + 7;
const double EPS = 0.000000001; // 1 e -9
const ll inf = (ll)1e18;
int n;
bool seen[1010];
/*int Query(vi v){
for(auto c : v) cout << c << " "; cout << endl;
int x; cin>>x; return x;
}
void Answer(vi v){
for(auto c : v) cout << c << " "; cout << endl;
}*/
void Solve(int N){
n = N;
vi ask(n , 0);
vi ans;
deque<int> dq;
dq.pb(1);
ask[0] = 1;
seen[1] = true;
while(dq.size() < n){
for(int i = 1 ; i <= n ; i++){
if(!seen[i]){
ask[i - 1] = 1;
if(Query(ask) == 1){
if(dq.size() == 1) dq.pb(i);
else{
vi v(n , 0);
v[dq.front() - 1] = 1;
v[i - 1] = 1;
if(Query(v) == 1) dq.push_front(i);
else dq.pb(i);
}
seen[i] = true;
break;
}
ask[i - 1] = 0;
}
}
}
for(auto c : dq){
ans.pb(c);
}
Answer(ans);
}
/*int main(){
//ifstream fin ("race.in");
//ofstream fout ("race.out");
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int N; cin>>N;
Solve(N);
return 0;
}*/
/*
Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO
Read the statement CAREFULLY !!
Make a GREADY APPROACH !!!! (start from highest / lowest)
Make your own TESTS !!
Be careful from CORNER CASES !
*/
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:50:21: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | while(dq.size() < n){
| ~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
292 KB |
# of queries: 8884 |
2 |
Correct |
163 ms |
292 KB |
# of queries: 8522 |
3 |
Correct |
130 ms |
200 KB |
# of queries: 8998 |
4 |
Correct |
136 ms |
288 KB |
# of queries: 9859 |
5 |
Correct |
147 ms |
288 KB |
# of queries: 10046 |
6 |
Correct |
156 ms |
200 KB |
# of queries: 9415 |
7 |
Correct |
173 ms |
200 KB |
# of queries: 9868 |
8 |
Correct |
93 ms |
356 KB |
# of queries: 9922 |
9 |
Correct |
177 ms |
200 KB |
# of queries: 9823 |
10 |
Correct |
75 ms |
200 KB |
# of queries: 4097 |
11 |
Correct |
1 ms |
264 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
200 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
200 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
200 KB |
# of queries: 6 |
15 |
Correct |
1 ms |
200 KB |
# of queries: 88 |
16 |
Correct |
3 ms |
200 KB |
# of queries: 236 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
292 KB |
# of queries: 8884 |
2 |
Correct |
163 ms |
292 KB |
# of queries: 8522 |
3 |
Correct |
130 ms |
200 KB |
# of queries: 8998 |
4 |
Correct |
136 ms |
288 KB |
# of queries: 9859 |
5 |
Correct |
147 ms |
288 KB |
# of queries: 10046 |
6 |
Correct |
156 ms |
200 KB |
# of queries: 9415 |
7 |
Correct |
173 ms |
200 KB |
# of queries: 9868 |
8 |
Correct |
93 ms |
356 KB |
# of queries: 9922 |
9 |
Correct |
177 ms |
200 KB |
# of queries: 9823 |
10 |
Correct |
75 ms |
200 KB |
# of queries: 4097 |
11 |
Correct |
1 ms |
264 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
200 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
200 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
200 KB |
# of queries: 6 |
15 |
Correct |
1 ms |
200 KB |
# of queries: 88 |
16 |
Correct |
3 ms |
200 KB |
# of queries: 236 |
17 |
Runtime error |
415 ms |
200 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |