답안 #263119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263119 2020-08-13T13:17:14 Z uacoder123 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) lli(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;

int n,m,d,g;
int ed[300001][2],lim=30000000,cur,ch=0,co=0,arr[2001],nex[300001],v1[300001],v2[300001],vis[300001];
vi al[150001];
bool cmp(int a,int b)
{
  return (a%m)<(b%m);
}
int dfs(int node)
{
  vis[node]=1;
  if(ed[node][0]==d||ed[node][1]==d)
  {
    v1[node]=(ed[node][1]==d)?1:0;
    return v1[node]+1;
  }
  int ans=-1;
  if(!vis[nex[node]])
    ans=dfs(nex[node]);
  else if(v1[nex[node]]!=-2)
    ans=(v1[nex[node]]==-1)?v1[nex[node]]+1:-1;
  v1[node]=ans;
  return (ans!=-1)?ans+1:ans;
}
void dfs1(int node)
{
  vis[node]=1;
  if(!vis[nex[node]])
    dfs1(nex[node]);
  else
  {
    if(v2[nex[node]]==-2)
    {
      cur=nex[node];
      ch=0;
      co=0;
      while(1)
      {
        if(ed[cur][0]==d||ed[cur][1]==d)
          ch=1;
        co++;
        if(cur==node)
          break;
        cur=nex[cur];
      }
      if(!ch)
        co=lim;
      v2[node]=co;
    }
    else
      v2[node]=v2[nex[node]];
    return;
  }
  v2[node]=v2[nex[node]];
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
  n=N;
  m=M;
  d=P;
  for(int i=0;i<m;++i)
  {
    ed[i][0]=R[i][0];
    ed[i][1]=R[i][1];
    ed[i+m][0]=R[i][1];
    ed[i+m][1]=R[i][0];
    al[R[i][0]].pb(i);
    al[R[i][1]].pb(i+m);
  }
  for(int i=0;i<n;++i)
    sort(all(al[i]),cmp);
  g=Q;
  for(int i=0;i<g;++i)
    arr[i]=G[i];
  for(int i=0;i<2*m;++i)
  {
    v1[i]=-2;
    v2[i]=-2;
    if(al[ed[i][1]].size()==1)
      nex[i]=al[ed[i][1]][0];
    else if(al[ed[i][1]][0]%m!=i%m)
      nex[i]=al[ed[i][1]][0];
    else
      nex[i]=al[ed[i][1]][1];
  }
  for(int i=0;i<2*m;++i)
    if(!vis[i])
      dfs(i);
  memset(vis,0,sizeof(vis));
  for(int i=0;i<2*m;++i)
    if(!vis[i])
      dfs1(i);
  for(int i=0;i<g;++i)
  {
    co=0;
    for(int j=0;j<n;++j)
    {
      if((arr[i]-v1[al[j][0]])%v2[al[j][0]]==0)
        co++;
    }
    answer(co);
  }
}

Compilation message

garden.cpp:21:1: error: 'vi' does not name a type; did you mean 'vis'?
   21 | vi al[150001];
      | ^~
      | vis
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:84:5: error: 'al' was not declared in this scope; did you mean 'all'?
   84 |     al[R[i][0]].pb(i);
      |     ^~
      |     all
garden.cpp:88:14: error: 'al' was not declared in this scope; did you mean 'all'?
   88 |     sort(all(al[i]),cmp);
      |              ^~
garden.cpp:9:17: note: in definition of macro 'all'
    9 | #define all(x) (x).begin(), (x).end()
      |                 ^
garden.cpp:96:8: error: 'al' was not declared in this scope; did you mean 'all'?
   96 |     if(al[ed[i][1]].size()==1)
      |        ^~
      |        all
garden.cpp:115:21: error: 'al' was not declared in this scope; did you mean 'all'?
  115 |       if((arr[i]-v1[al[j][0]])%v2[al[j][0]]==0)
      |                     ^~
      |                     all