제출 #1275141

#제출 시각아이디문제언어결과실행 시간메모리
1275141hihihihaw원숭이와 사과 나무 (IZhO12_apple)C++20
100 / 100
353 ms165388 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pii pair<int,int> #define sz(v) (int)v.size() #define fi first #define se second #define INF 1223372036854775807 #define INF2 122337203 #define MOD 1000000009 #define cint(x) int x;cin>>x; #define cinarr(a,n) int a[n];for (int i=0;i<n;i++) cin>>a[i]; #define coutarr(a) for (auto d:a)cout<<d<<" "; cout<<endl; #define coutarrD(a) for (auto d:a) cout<<d.fi<<","<<d.se<<" "; cout<<endl; #define BERKAY_TUP ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define endl '\n' #define ld long double #define mid (start+end)/2 #define vvi vector<vector<int>> int t=1; int interactive=0; int usaco=0; int testCase=0; vector<int> lft; vector<int> rght; vector<int> acc; vector<int> total; int c=2; void push(int n,int start,int end){ if (acc[n]){ acc[lft[n]]=1; acc[rght[n]]=1; total[lft[n]]=mid-start+1; total[rght[n]]=end-mid; } } void update(int n,int start,int end,int l,int r){ if (start>end || start>r || end<l){return;} if (start>=l && end<=r){ acc[n]=1; total[n]=end-start+1; return; } if (lft[n]==0){ lft[n]=c; c++; lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); } if (rght[n]==0){ rght[n]=c; c++; lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); } push(n,start,end); update(lft[n],start,mid,l,r); update(rght[n],mid+1,end,l,r); total[n]=total[lft[n]]+total[rght[n]]; } int query(int n,int start,int end,int l,int r){ if (start>end || start>r || end<l) return 0; if (start>=l && end<=r) return total[n]; if (lft[n]==0){ lft[n]=c; c++; lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); } if (rght[n]==0){ rght[n]=c; c++; lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); } push(n,start,end); return query(lft[n],start,mid,l,r)+query(rght[n],mid+1,end,l,r); } void solve(){ lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); lft.pb(0); rght.pb(0); acc.pb(0); total.pb(0); int q; cin>>q; int k=0; while (q--){ int a,b,c; cin>>a>>b>>c; if (a==2) update(1,1,1000000000,b+k,c+k); else{ k=query(1,1,1000000000,b+k,c+k); cout<<k<<endl; } } //cout<<23<<endl; } int32_t main(){ BERKAY_TUP; if (usaco){ freopen("team.in", "r", stdin); freopen("team.out", "w", stdout); } if (!interactive){ #ifdef Local freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); //freopen("wormsort.out", "w", stdout); #endif } if (t==1) solve(); else{ cin>>t; while (t--){testCase++;solve();} } return 0; }

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

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