이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
#define int long long
#define all(a) a.begin(), a.end()
#define rep(i,n) for(int i = 0; i<n; i++)
using namespace std;
struct s
{
int m=0,l=0,r=0, ar=0;
};
s unite(s s1, s s2)
{
s res;
res.ar=s1.ar+s2.ar;
res.m=max({s1.m,s2.m,s1.r+s2.l});
res.l=s1.l;
res.r=s2.r;
if(s1.l==s1.ar) res.l+=s2.l;
if(s2.r==s2.ar) res.r+=s1.r;
return res;
}
s def=s();
int N = 100000;
vector<s>T(4*N);
s update(int i, int l, int r, int ui, int uv)
{
if(l>ui||r<=ui) return T[i];
if(l+1==r) return T[i]=s({uv,uv,uv,1});
return T[i] = unite(update(2*i,l,(l+r)/2,ui,uv), update(2*i+1,(l+r)/2,r,ui,uv));
}
s query(int i, int l, int r, int ql, int qr)
{
if(l>=qr||r<=ql) return def;
if(l>=ql&&r<=qr) return T[i];
return unite(query(2*i,l,(l+r)/2,ql,qr),query(2*i+1,(l+r)/2,r,ql,qr));
}
vector<int> minimum_costs(vector<signed> H,vector<signed> L,
vector<signed> R) {
int n = H.size();
rep(i,n) update(1,0,n,i,H[i]==1);
vector<int>C(L.size());
rep(cq, L.size()) C[cq]=2*(R[cq] - L[cq] + 1) - query(1,0,n,L[cq], R[cq]+1).m;
return C;
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:7:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | #define rep(i,n) for(int i = 0; i<n; i++)
......
52 | rep(cq, L.size()) C[cq]=2*(R[cq] - L[cq] + 1) - query(1,0,n,L[cq], R[cq]+1).m;
| ~~~~~~~~~~~~
meetings.cpp:52:3: note: in expansion of macro 'rep'
52 | rep(cq, L.size()) C[cq]=2*(R[cq] - L[cq] + 1) - query(1,0,n,L[cq], R[cq]+1).m;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |