# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471626 | ToroTN | Pilot (NOI19_pilot) | C++14 | 874 ms | 79632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n,m,a,chk[1000005],p[1000005],node,fuck;
long long cnt=0,ans[1000005],l,r;
vector<int> v[1000005];
int f(int a)
{
if(p[a]==a)
{
return a;
}
return p[a]=f(p[a]);
}
void un(int b,int c)
{
chk[f(c)]+=chk[f(b)];
p[f(b)]=f(c);
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%d",&a);
v[a].push_back(i);
chk[i]=1;
}
for(int i=1;i<=1000000;i++)
{
for(int j=0;j<v[i].size();j++)
{
node=v[i][j];
chk[node]=1;
p[node]=node;
l=(long long)(chk[f(node-1)]);
r=(long long)(chk[f(node+1)]);
if(l==0&&r==0)
{
cnt+=1;
}else if(l==0)
{
cnt+=r+(long long)1;
}else if(r==0)
{
cnt+=l+(long long)1;
}else
{
cnt+=(l+(long long)1)*(r+(long long)1);
}
//printf("%lld\n",cnt);
if(p[node-1]!=0)
{
un(node-1,node);
}
if(p[node+1]!=0)
{
un(node+1,node);
}
/*for(int k=1;k<=n;k++)
{
printf("%d ",chk[f(k)]);
}
printf("\n\n");*/
}
ans[i]=cnt;
}
while(m--)
{
scanf("%d",&fuck);
printf("%lld\n",ans[fuck]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |
# | 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... |