# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
736319 |
2023-05-05T12:38:11 Z |
beaconmc |
Nizovi (COI14_nizovi) |
C++14 |
|
202 ms |
332 KB |
#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;
}
if (i!=0 && stuff[i] == stuff[i-1]){
pos += 1;
cur -= 1;
continue;
}
if (pos < stuff[i]) cout << "reverse " << pos << " " << stuff[i] << endl;
if (pos < stuff[i]-cur) cout << "reverse " << pos << " " << stuff[i]-cur << endl;
if (stuff[i]-cur+1 < stuff[i]) cout << "reverse " << stuff[i]-cur+1 << " "<< stuff[i]<< endl;
cur -= 1;
pos = stuff[i]-cur+1;
}
cout << "end" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
37 ms |
208 KB |
Output is correct |
5 |
Correct |
48 ms |
332 KB |
Output is correct |
6 |
Correct |
47 ms |
208 KB |
Output is correct |
7 |
Correct |
164 ms |
280 KB |
Output is correct |
8 |
Correct |
179 ms |
280 KB |
Output is correct |
9 |
Correct |
202 ms |
280 KB |
Output is correct |
10 |
Incorrect |
143 ms |
292 KB |
Total cost of reverse commands > 3 000 000 |