Submission #224487

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2244872020-04-18 05:08:49maximath_1Pilot (NOI19_pilot)C++14
100 / 100
970 ms45116 KiB
#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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

pilot.cpp: In function 'int main()':
pilot.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~
pilot.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &h[i].first);
   ~~~~~^~~~~~~~~~~~~~~~~~~
pilot.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &h);
   ~~~~~^~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...