Submission #682213

#TimeUsernameProblemLanguageResultExecution timeMemory
682213vjudge1Food Court (JOI21_foodcourt)C++17
7 / 100
1094 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/rope> using namespace __gnu_cxx; // #pragma comment(linker, "/stack:2000000000") // #pragma GCC optimize("Ofast") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; #define precise(a) cout<<fixed<<setprecision(a) #define sz size() #define ff first #define ss second #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(), a.rend() #define pb push_back // t1 const ll mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6 const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod const ll N = ll(3e5)+10; const ll K = 17; const ll inf = 1e18; const ld eps = 1e-15L; //const ll B = 316; ll lcm(ll a, ll b){ return (a / __gcd(a,b)) * b; } //const ld P = acos(-1.0); // ll binpow(ll a, ll b, ll m){ ll res=1;a%=m; while(b>0){ if(b&1)res=(res*a)%m; a=(a*a)%m; b/=2; } return res%m;} ld binpow(ld a, ll b){ ld res=1; while(b>0){ if(b&1)res=(res*a); a=(a*a); b/=2; } return res;} void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); } void precalc() { } ll n, m, q; vector<pll>cus[N]; ll debt[N]; void Baizho() { cin>>n>>m>>q; while(q--) { ll t; cin>>t; if(t==1) { ll l, r, shop, k; cin>>l>>r>>shop>>k; for(ll i=l; i<=r; i++) { ll extra = 0; if(cus[i].sz) { extra = cus[i].back().ff; if(cus[i].back().ss==shop) { cus[i].pop_back(); } } cus[i].pb({k+extra, shop}); } } else if(t==2) { ll l, r, k; cin>>l>>r>>k; for(ll i=l; i<=r; i++) { if(cus[i].sz) debt[i]+=min(cus[i].back().ff-debt[i], k); } } else { ll shop, pos; cin>>shop>>pos; pos+=debt[shop]; if(cus[shop].sz==0) cout<<"0\n"; else if(pos>cus[shop].back().ff) cout<<"0\n"; else cout<<(*lower_bound(all(cus[shop]), make_pair(pos, 0ll))).ss<<"\n"; } } } int main() { // Freopen("div7"); ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); precalc(); int ttt = 1; // cin>>ttt; for(int i=1; i<=ttt; i++) { Baizho();} }

Compilation message (stderr)

foodcourt.cpp: In function 'void Freopen(std::string)':
foodcourt.cpp:37:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
      |                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:37:76: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...