제출 #434968

#제출 시각아이디문제언어결과실행 시간메모리
434968cpp219Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
8 ms1100 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 1e3 + 9; const ll inf = 1e9 + 7; struct Node{ vector<ll> v; ll inv; }; Node st[4*N],spare; ll n,Q,a[N]; Node Combine(Node lf,Node rg){ Node now; now.inv = max(lf.inv,rg.inv); if (rg.v.size() && lf.v.size()){ auto it = prev(upper_bound(rg.v.begin(),rg.v.end(),lf.v.back())); if (it != rg.v.end()) now.inv = max(now.inv,*it + lf.v.back()); } ll st1 = 0,st2 = 0; while(st1 < lf.v.size() || st2 < rg.v.size()){ ll x = inf,y = inf; if (st1 < lf.v.size()) x = lf.v[st1]; if (st2 < rg.v.size()) y = rg.v[st2]; if (x < y) now.v.push_back(x),st1++; else now.v.push_back(y),st2++; //cout<<x<<" "<<y; exit(0); } return now; } void build(ll id,ll l,ll r){ //cout<<id<<" "<<l<<" "<<r<<"\n"; if (l == r){ st[id].v.push_back(a[l]); st[id].inv = 0; return; } ll mid = (l + r)/2; build(id*2,l,mid); build(id*2 + 1,mid + 1,r); st[id] = Combine(st[id*2],st[id*2 + 1]); } Node Get(ll id,ll l,ll r,ll u,ll v){ if (v < l||r < u) return spare; if (u <= l&&r <= v) return st[id]; ll mid = (l + r)/2; return Combine(Get(id*2,l,mid,u,v),Get(id*2 + 1,mid + 1,r,u,v)); } ll l,r,k; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>Q; for (ll i = 1;i <= n;i++) cin>>a[i]; build(1,1,n); //cout<<st[4].inv; return 0; while(Q--){ cin>>l>>r>>k; Node now = Get(1,1,n,l,r); //cout<<now.inv; return 0; cout<<(now.inv <= k)<<"\n"; } }

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

sortbooks.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
sortbooks.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
sortbooks.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
sortbooks.cpp: In function 'Node Combine(Node, Node)':
sortbooks.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     while(st1 < lf.v.size() || st2 < rg.v.size()){
      |           ~~~~^~~~~~~~~~~~~
sortbooks.cpp:31:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     while(st1 < lf.v.size() || st2 < rg.v.size()){
      |                                ~~~~^~~~~~~~~~~~~
sortbooks.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (st1 < lf.v.size()) x = lf.v[st1];
      |             ~~~~^~~~~~~~~~~~~
sortbooks.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (st2 < rg.v.size()) y = rg.v[st2];
      |             ~~~~^~~~~~~~~~~~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...