#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef int ll;
using namespace std;
//using namespace __gnu_pbds;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
//#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main(){
ll a,b;
cin >> a >> b;
ll stuff[a];
FOR(i,0,a){
ll lo = a+1;
ll hi = a+b+1;
cout << "cmp " << i+1 << " " << a+1 << endl;
ll resp; cin >> resp;
if (resp == -1){
stuff[i] = -1;
continue;
}
while (lo < hi){
ll mid = (hi + lo) / 2;
cout << "cmp " << i+1 << " " << mid << endl;
ll resp;
cin >> resp;
if (resp<=0){
hi = mid;
}else{
lo = mid+1;
}
}
stuff[i] = lo-1;
}
ll cur = a;
ll pos = 1;
FOR(i,0,a){
if (stuff[i] == -1){
pos += 1;
cur -= 1;
continue;
}
cout << "reverse " << pos << " " << stuff[i] << endl;
cout << "reverse " << pos << " " << stuff[i]-cur << endl;
cout << "reverse " << stuff[i]-cur+1 << " "<< stuff[i]<< endl;
cur -= 1;
pos = stuff[i]-cur+1;
}
cout << "end" << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Integer 0 violates the range [1, 30] |
2 |
Incorrect |
3 ms |
208 KB |
x > y in reverse command |
3 |
Incorrect |
5 ms |
208 KB |
x > y in reverse command |
4 |
Runtime error |
56 ms |
280 KB |
Execution killed with signal 13 |
5 |
Runtime error |
54 ms |
276 KB |
Execution killed with signal 13 |
6 |
Incorrect |
22 ms |
284 KB |
Integer 0 violates the range [1, 1000] |
7 |
Runtime error |
227 ms |
296 KB |
Execution killed with signal 13 |
8 |
Incorrect |
240 ms |
276 KB |
x > y in reverse command |
9 |
Correct |
191 ms |
276 KB |
Output is correct |
10 |
Runtime error |
251 ms |
296 KB |
Execution killed with signal 13 |