Submission #1248171

#TimeUsernameProblemLanguageResultExecution timeMemory
1248171CrabCNHWorst Reporter 3 (JOI18_worst_reporter3)C++20
0 / 100
6 ms1856 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) #define all(v) (v).begin(), (v).end() typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; template <class T> void minimize (T &t, T f) {if (t > f) t = f;} template <class T> void maximize (T &t, T f) {if (t < f) t = f;} const int maxN = 2e5 + 5; const int inf = 1e18 + 7; const int mod = 1e9 + 7; // khong tu code thi khong kha len duoc dau struct Que { int t, l, r; }; int n, q; int d[maxN]; Que off[maxN]; namespace sub1 { bool check () { int cnt = 0; for (int i = 1; i <= n; i ++) { cnt += (d[i] == 1); } return (cnt == n); } void sol () { for (int i = 1; i <= q; i ++) { auto [t, l, r] = off[i]; int L = - n + t; int R = t; //cout << L << ' ' << R << ' ' << l << ' ' << r << '\n'; if (R < l || r < L) { cout << 0; } else { cout << min (r, R) - max (l, L) + 1; } cout << '\n'; } } } void solve () { cin >> n >> q; for (int i = 1; i <= n; i ++) { cin >> d[i]; } for (int i = 1; i <= n; i ++) { int t, l, r; cin >> t >> l >> r; off[i] = {t, l, r}; } if (sub1 :: check ()) { sub1 :: sol (); return; } return; } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { solve (); } return 0; } // thfv

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:82:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:83:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...