Submission #955655

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9556552024-03-31 09:15:54Alexabcde1Railway (BOI17_railway)C++14
100 / 100
226 ms70604 KiB
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
long long n,m,k,aa,bb,cnt,ind[100005],t,timer,in[100005],out[100005],par[100005][50],psum[100005],vis[100005],vis2[100005];
vector<pair<long long,long long> > ve;
vector<long long> adj[100005];
map<pair<long long,long long>,long long> mp;
vector<long long> ans;
void dfs(long long x,long long pre){
vis[x]=1;
in[x]=timer; timer++;
par[x][0]=pre;
for (int i=1;i<=40;i++) par[x][i]=par[par[x][i-1]][i-1];
cnt++;
ind[x]=cnt;
for (int ii=0;ii<adj[x].size();ii++){
if (!vis[adj[x][ii]]) dfs(adj[x][ii],x);
}
out[x]=timer; timer++;
return;
}
bool an(long long u,long long v){
return in[u]<=in[v] && out[u]>=out[v];
}
long long lca(long long u,long long v){
if (an(u,v)) return u;
if (an(v,u)) return v;
for (int i=39;i>=0;--i){
if (!an(par[u][i],v)) u=par[u][i];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

railway.cpp: In function 'void dfs(long long int, long long int)':
railway.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int ii=0;ii<adj[x].size();ii++){
      |                ~~^~~~~~~~~~~~~~
railway.cpp: In function 'void dfs2(long long int, long long int)':
railway.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i=0;i<adj[x].size();i++){
      |               ~^~~~~~~~~~~~~~
railway.cpp: In function 'int main()':
railway.cpp:79:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |  for (int i=0;i<ans.size();i++){
      |               ~^~~~~~~~~~~
#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...