(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #1119633

#제출 시각아이디문제언어결과실행 시간메모리
1119633InvMODHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
64 / 100
144 ms19276 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define gcd __gcd #define sz(v) (int) v.size() #define pb push_back #define pi pair<int,int> #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define dbg(x) "[" #x " = " << (x) << "]" ///#define int long long using ll = long long; using ld = long double; using ull = unsigned long long; template<typename T> bool ckmx(T& a, const T& b){if(a < b) return a = b, true; return false;} template<typename T> bool ckmn(T& a, const T& b){if(a > b) return a = b, true; return false;} const int N = 2e5+5; const ll MOD = 1e9+7; const ll INF = 1e18; int n, m, a[N], ql[N], mood[N], answer[N], bit[N]; vector<int> Query[N]; void update(int p, int val){ for(; p > 0; p -= p&-p){ bit[p] = max(bit[p], val); } return; } int get(int p){ int res = 0; for(; p <= n; p += p&-p){ res = max(res, bit[p]); } return res; } void solve() { cin >> n >> m; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, m){ int l,r,mo; cin >> l >> r >> mo; Query[r].push_back(i); ql[i] = l, mood[i] = mo; } stack<int> s; a[0] = INT_MAX; s.push(0); FOR(idR, 1, n){ while(a[idR] >= a[s.top()]) s.pop(); if(s.top()){ update(s.top(), a[idR] + a[s.top()]); } for(int id : Query[idR]){ int l = ql[id], mood_have = mood[id]; int Mx = get(l); if(mood_have < Mx){ answer[id] = 0; } else{ answer[id] = 1; } } s.push(idR); } FOR(i, 1, m) cout << answer[i] <<"\n"; return; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP","r",stdin); freopen(name".OUT","w",stdout); } int t = 1; //cin >> t; while(t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:95:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:96:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...