이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define NMAX 1010
//#define int long long
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define nl '\n'
#define INF 1000000007
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int,int>
//#pragma GCC optimize("O3")
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
*
*
----------------DEMONSTRATION-------------------
1 2 2 3 4 2
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 4 5
---------------------END------------------------
*/
int n;
vector<int>v;
vector<int>ans;
class segtree{
private:
int n;
vector<int>tree;
vector<int>lazy;
public:
void init(int sz)
{
n=sz;
tree.resize(4*sz+1);
lazy.resize(4*sz+1);
}
void push(int node,int L,int R)
{
if(lazy[node])
{
tree[node] = lazy[node];
if(L != R)
{
lazy[2*node] = lazy[node];
lazy[2*node+1] = lazy[node];
}
lazy[node] = 0;
}
}
void update_lazy(int node,int st,int dr,int L,int R,int val)
{
push(node,st,dr);
if(st>R || dr<L)
return;
if(L<=st && dr<=R)
{
lazy[node]=val;
push(node,st,dr);
return;
}
int mid=(st+dr)/2;
update_lazy(2*node,st,mid,L,R,val);
update_lazy(2*node+1,mid+1,dr,L,R,val);
tree[node]=max(tree[2*node],tree[2*node+1]);
}
void update(int node,int st,int dr,int pos,int val)
{
if(st==dr)
{
tree[node]=val;
return;
}
int mid=(st+dr)/2;
if(pos<=mid)
update(2*node,st,mid,pos,val);
else
update(2*node+1,mid+1,dr,pos,val);
tree[node]=max(tree[2*node],tree[2*node+1]);
}
int last_stone(int node,int st,int dr,int L,int R,int val)
{
push(node,st,dr);
if(tree[node]<val || st>R || dr<L)
return 0;
if(st==dr)
{
if(tree[node]==val)
return st;
else
return 0;
}
int mid=(st+dr)/2;
int ans= last_stone(2*node+1,mid+1,dr,L,R,val);
if(ans==0)
ans= last_stone(2*node,st,mid,L,R,val);
return ans;
}
void print(int node,int st,int dr)
{
push(node,st,dr);
if(st==dr)
{
ans[st]=tree[node];
return;
}
int mid=(st+dr)/2;
print(2*node,st,mid);
print(2*node+1,mid+1,dr);
}
void update(int pos,int val)
{
update(1,1,n,pos,val);
}
int last(int L,int R,int val)
{
if(L>R)
return 0;
return last_stone(1,1,n,L,R,val);
}
void update_lazy(int L,int R,int val)
{
update_lazy(1,1,n,L,R,val);
}
};
segtree seg;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
v.resize(n+1);
ans.resize(n+1);
for(int i=1;i<=n;++i)
{
cin>>v[i];
}
map<int,int>mp;
for(int i=1;i<=n;++i)
{
mp[v[i]]=i;
}
int cur=1;
while(cur!=n+1)
{
int next=mp[v[cur]]+1;
for(int i=cur;i<next;++i)
ans[i]=v[cur];
cur=next;
}
for(int i=1;i<=n;++i)
{
cout<<ans[i]<<nl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:9: warning: "LLONG_MAX" redefined
9 | #define LLONG_MAX 9223372036854775807
|
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
from /usr/include/c++/10/climits:42,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
from Main.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
135 | # define LLONG_MAX __LONG_LONG_MAX__
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |