Submission #670265

# Submission time Handle Problem Language Result Execution time Memory
670265 2022-12-08T13:53:46 Z MilosMilutinovic Jail (JOI22_jail) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#include<cassert>
#define pb push_back
#define mk make_pair
using namespace std;
int n,m,go[120005][22],dep[120005],s[120005],t[120005];
void dfs(int v,int pr)
{
    go[v][0]=pr;
    for(int u:e[v])if(u!=pr)dep[u]=dep[v]+1,dfs(u,v);
}
int lca(int u,int v)
{
    if(dep[u]<dep[v])swap(u,v);
    for(int i=19;i>=0;i--)if(dep[go[u][i]]>=dep[v])u=go[u][i];
    for(int i=19;i>=0;i--)if(go[u][i]!=go[v][i])u=go[u][i],v=go[v][i];
    return u==v?u:go[u][0];
}
int deg[120005];vector<int> e[120005];
void init(){for(int i=1;i<=m;i++)deg[i]=0,e[i].clear();}
void adde(int x,int y){deg[y]++;e[x].pb(y);}
bool on(int x,int y,int z){int l=lca(x,y);return in(l,z)&&in(z,x)&&in();}
void solve()
{
    scanf("%d",&n);
    dfs(1,1);
    for(int i=1;i<=n;i++)for(int j=1;j<20;j++)go[i][j]=go[go[i][j-1]][j-1];
    scanf("%d",&m);
    for(int i=1;i<=m;i++)scanf("%d%d",&s[i],&t[i]);
    init();
    for(int i=1;i<=m;i++)for(int j=1;j<=m;j++)if(i!=j&&on(s[i],t[i],s[j]))adde(j,i);
}
int main()
{
    int t;scanf("%d",&t);
    while(t--)solve();
    return 0;
}

Compilation message

jail.cpp: In function 'void dfs(int, int)':
jail.cpp:23:15: error: 'e' was not declared in this scope
   23 |     for(int u:e[v])if(u!=pr)dep[u]=dep[v]+1,dfs(u,v);
      |               ^
jail.cpp: In function 'bool on(int, int, int)':
jail.cpp:35:50: error: 'in' was not declared in this scope; did you mean 'on'?
   35 | bool on(int x,int y,int z){int l=lca(x,y);return in(l,z)&&in(z,x)&&in();}
      |                                                  ^~
      |                                                  on
jail.cpp: In function 'void solve()':
jail.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
jail.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
jail.cpp:42:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     for(int i=1;i<=m;i++)scanf("%d%d",&s[i],&t[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~
jail.cpp: In function 'int main()':
jail.cpp:48:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     int t;scanf("%d",&t);
      |           ~~~~~^~~~~~~~~