Submission #883443

#TimeUsernameProblemLanguageResultExecution timeMemory
883443catloverRuka (COI15_ruka)C++14
9 / 100
2041 ms3816 KiB
// Author : Hoang Van Tra - HSGS Bac Giang // Train VOI 2023 - 2024 #include <bits/stdc++.h> using namespace std; // -------------------------------------------------------INDEF----------------------------------------------------------------------- #define For(i, a, b) for (int i = a; i <= b; i++) #define Ford(i, a, b) for (int i = a; i >= b; i--) #define ll long long #define ii pair<int, int> #define fi first #define se second #define all(v) v.begin(), v.end() #define RRH(v) v.resize(unique(all(v)) - v.begin()) const int N = 1e6 + 7; const int M = 1e9 + 7; const ll oo = 1e18; const int block = 708; int n, q; ii a[N]; int solve() { int ans = 0; int x = 1, y = 1; int cur_x = 1; int cur_y = 1; For(i, 1, n) { x += a[i].fi; y += a[i].se; if (cur_x * x < 0) { ans++; cur_x = -cur_x; } if (cur_y * y < 0) { ans++; cur_y = -cur_y; } } return ans; } // -------------------------------------------------------ENDEF---------------------------------------------------------------------- int32_t main() { ios::sync_with_stdio(0); cin.tie(0); #define TASK "" if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } cin >> n; For(i, 1, n) cin >> a[i].fi >> a[i].se; cin >> q; a[0] = { 1, 1 }; int pos = 1; while (q--) { char t; cin >> t; if (t == 'B') pos = max(1, pos - 1); if (t == 'F') pos = min(n, pos + 1); if (t == 'C') { int x, y; cin >> x >> y; a[pos] = { x, y }; } if (t == 'Q') cout << solve() << "\n"; } return 0; }

Compilation message (stderr)

ruka.cpp: In function 'int32_t main()':
ruka.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
ruka.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
ruka.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ruka.cpp:59:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...