# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224487 | maximath_1 | Pilot (NOI19_pilot) | C++14 | 970 ms | 45116 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=1e6+5;
int n, q, par[mxn], sz[mxn];
pair<int, int>h[mxn];
bool vis[mxn];
int f(int a){return par[a]=(par[a]==a)?a:f(par[a]);}
ll calc(int x){return (ll)sz[f(x)]*(sz[f(x)]+1)/2;}
int main(){
scanf("%d%d", &n, &q);
for(int i=0; i<n; i++){
scanf("%d", &h[i].first);
h[i].second=i; par[i]=i;
vis[i]=false; sz[i]=1;
}
vector<ll>val;
vector<int>id;
id.push_back(0); val.push_back(0ll);
sort(h, h+n);
ll v=0ll, vt=0ll; int tmp=h[0].first;
for(int i=0; i<n; i++){
if(h[i].second>0 && vis[h[i].second-1]){
int uu=h[i].second, vv=h[i].second-1;
v-=calc(vv);
uu=f(uu); vv=f(vv);
sz[uu]+=sz[vv]; par[vv]=uu;
}
if(h[i].second<n-1 && vis[h[i].second+1]){
int uu=h[i].second, vv=h[i].second+1;
컴파일 시 표준 에러 (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... |