Submission #24180

#TimeUsernameProblemLanguageResultExecution timeMemory
24180chpipisNizovi (COI14_nizovi)C++11
100 / 100
73 ms2024 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define pf push_front #define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++) #define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL) #define all(v) (v).begin(), (v).end() #define rep(i, s, e) for (int i = s; i < e; i++) #ifdef __linux__ #define gc getchar_unlocked #define pc putchar_unlocked #else #define gc getchar #define pc putchar #endif #if __cplusplus <= 199711L template<class BidirIt> BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) { advance(it, -n); return it; } template<class ForwardIt> ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) { advance(it, n); return it; } #endif typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef long double ldouble; const double EPS = 1e-9; const double PI = 3.141592653589793238462; template<typename T> inline T sq(T a) { return a * a; } //#ifdef LOCAL_MACHINE //#endif ll ops = 0, cost = 0; int comp(int i, int j) { if (i == j) return 0; ops++; assert(ops <= ( ll )1e5); printf("cmp %d %d\n", i, j); fflush(stdout); int res; scanf("%d", &res); return res; } void rev(int i, int j) { if (i >= j) return; cost += j - i + 1; ops++; assert(cost <= ( ll )3e6); assert(ops <= ( ll )1e5); printf("reverse %d %d\n", i, j); fflush(stdout); } int aft[1005]; int main() { //freopen("", "r", stdin); //freopen("", "w", stdout); int len_a, len_b; scanf("%d %d", &len_a, &len_b); for (int a = 1; a <= len_a; a++) { int lo = len_a, hi = len_a + len_b; while (lo < hi) { int mid = (lo + hi + 1) >> 1; if (comp(a, mid) <= 0) hi = mid - 1; else lo = mid; } aft[a] = lo; } int cnt = 0; for (int i = 1; i <= len_a; i++) { if (aft[i] == aft[i - 1]) continue; if (aft[i] == len_a) continue; int a = i + cnt; //cerr << "wanting to place " << a << " after " << aft[i] << endl; int cur = (aft[i] - a + 1) - (len_a - i + 1); rev(a, aft[i]); rev(a, a + cur - 1); rev(a + cur, aft[i]); cnt += cur; } puts("end"); fflush(stdout); return 0; }

Compilation message (stderr)

nizovi.cpp: In function 'int comp(int, int)':
nizovi.cpp:61:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &res);
                      ^
nizovi.cpp: In function 'int main()':
nizovi.cpp:81:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &len_a, &len_b);
                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...