Submission #578694

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5786942022-06-17 15:56:21WongChun1234Ideal city (IOI12_city)C++14
100 / 100
578 ms47496 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100050;
const ll MOD=1000000000;
const bool DEBUG=0;
int n,cx,cnt[N],grpcnt,ingrp[N];
ll ans,dist[N];
vector<pair<int,int>> curr,grps[N];
pair<int,int> coord[N];
map<int,vector<pair<int,int>>> mp;
map<pair<int,int>,int> hv;
ll f(ll num){
return (1+num)*num/2%MOD;
}
void dfs(int nde,int par,pair<int,int> connection,bool up){
vector<array<ll,2>> frntsum,frntcnt,bcksum,bckcnt;
int cx=coord[grps[nde][0].second-1].first,cy=INT_MAX,cz=grps[nde].size();
ll csum=0,ccnt=0,lzsum=0,lzcnt=0,dup=0;
frntsum.resize(cz); frntcnt.resize(cz); bcksum.resize(cz); bckcnt.resize(cz);
if (DEBUG) cerr<<"dfs"<<cx<<"::"<<connection.first<<","<<connection.second<<"\n";
for (auto i:grps[nde]){
if (!hv[{cx+1,i.first}]) continue;
if (ingrp[hv[{cx+1,i.first}]]==par) continue;
cy=min(cy,i.first);
if (hv[{cx+1,i.first+1}]&&i!=grps[nde].back()) continue;
dfs(ingrp[hv[{cx+1,i.first}]],nde,{cy,i.first},0);
cy=INT_MAX;
}
cy=INT_MAX;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...