Submission #1095428

# Submission time Handle Problem Language Result Execution time Memory
1095428 2024-10-02T07:40:37 Z MtSaka Tropical Garden (IOI11_garden) C++17
Compilation error
0 ms 0 KB
#include"bits/stdc++.h"
#include "garden.h"
#include "gardenlib.h"
#define overload(a,b,c,d,...) d
#define rep1(a) for(ll _=0;_<(ll)a;++_)
#define rep2(i,a) for(ll i=0;i<(ll)(a);++i)
#define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) overload(__VA_ARGS__,rep2,rep1,rep1)(__VA_ARGS__)
#define rrep1(i,a) for(ll i=(ll)(a)-1;i>=0;--i)
#define rrep2(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);--i)
#define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using ld=long double;
using vi=vector<int>;
using vl=vector<ll>;
template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);}
template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);}

int count_routes(int n,int m,int p,int r[][2],int q,int query[]){
    vector<int>to(2*n,-1);
    vector<int>cnt(n);
    vector<int>deg(n);
    rep(i,m){
        deg[r[i][0]]++,deg[r[i][1]]++;
    }
    rep(i,m){
        int u=r[i][0],v=r[i][1];
        if(cnt[u]>cnt[v])swap(u,v);
        if(cnt[u]==0&&cnt[v]==0){
            to[u]=(deg[v]>1?v+n:v);
            to[v]=(deg[u]>1?u+n:u);
        }
        else if(cnt[u]==0&&cnt[v]==1){
            to[v+n]=(deg[u]>1?u+n:u);
            to[u]=v;
        }
        else if(cnt[u]==0){
            to[u]=v;
        }
        if(cnt[u]==1&&cnt[v]==1){
            to[u+n]=v;
            to[v+n]=u:
        }
        else if(cnt[u]==1){
            to[u+n]=v;
        }
        cnt[u]++,cnt[v]++;
    }
    rep(i,n)if(to[i+n]==-1)to[i+n]=to[i];
    vector<int>dist1(2*n,-1),dist2(2*n,-1);
    vector<vector<int>>rg(2*n);
    for(int i=0;i<2*n;++i)rg[to[i]].eb(i);
    {
        queue<int>que;
        que.emplace(p);
        dist1[p]=0;
        while(!que.empty()){
            int v=que.front();que.pop();
            for(auto u:g[v])if(dist1[u]==-1){
                dist1[u]=dist1[v]+1;
                que.emplace(u);
            }
        }
    }
    {
        queue<int>que;
        que.emplace(p+n);
        dist2[p+n]=0;
        while(!que.empty()){
            int v=que.front();que.pop();
            for(auto u:g[v])if(dist2[u]==-1){
                dist2[u]=dist2[v]+1;
                que.emplace(u);
            }
        }
    }
    int cycle1=1e9,cycle2=1e9;
    {
        int now=p;
        rep(i,1,2*n+1){
            now=to[now];
            if(now==p){
                cycle1=i;
                break;
            }
        }
    }
    {
        int now=p+n;
        rep(i,1,2*n+1){
            now=to[now];
            if(now==p+n){
                cycle2=i;
                break;
            }
        }
    }
    rep(i,q){
        int k=query[i];
        int ans=0;
        rep(j,n){
            if(k>=dist1[j]&&(k-dist1[j])%cycle1==0)ans++;
            else if(k>=dist2[j]&&(k-dist2[j])%cycle2==0)ans++;
        }
        answer(ans);
    }
}

Compilation message

garden.cpp:30:12: error: macro "rep1" passed 2 arguments, but takes just 1
   30 |     rep(i,m){
      |            ^
garden.cpp:5: note: macro "rep1" defined here
    5 | #define rep1(a) for(ll _=0;_<(ll)a;++_)
      | 
garden.cpp:33:12: error: macro "rep1" passed 2 arguments, but takes just 1
   33 |     rep(i,m){
      |            ^
garden.cpp:5: note: macro "rep1" defined here
    5 | #define rep1(a) for(ll _=0;_<(ll)a;++_)
      | 
garden.cpp:56:12: error: macro "rep1" passed 2 arguments, but takes just 1
   56 |     rep(i,n)if(to[i+n]==-1)to[i+n]=to[i];
      |            ^
garden.cpp:5: note: macro "rep1" defined here
    5 | #define rep1(a) for(ll _=0;_<(ll)a;++_)
      | 
garden.cpp:87:22: error: macro "rep2" passed 3 arguments, but takes just 2
   87 |         rep(i,1,2*n+1){
      |                      ^
garden.cpp:6: note: macro "rep2" defined here
    6 | #define rep2(i,a) for(ll i=0;i<(ll)(a);++i)
      | 
garden.cpp:97:22: error: macro "rep2" passed 3 arguments, but takes just 2
   97 |         rep(i,1,2*n+1){
      |                      ^
garden.cpp:6: note: macro "rep2" defined here
    6 | #define rep2(i,a) for(ll i=0;i<(ll)(a);++i)
      | 
garden.cpp:105:12: error: macro "rep1" passed 2 arguments, but takes just 1
  105 |     rep(i,q){
      |            ^
garden.cpp:5: note: macro "rep1" defined here
    5 | #define rep1(a) for(ll _=0;_<(ll)a;++_)
      | 
garden.cpp:108:16: error: macro "rep1" passed 2 arguments, but takes just 1
  108 |         rep(j,n){
      |                ^
garden.cpp:5: note: macro "rep1" defined here
    5 | #define rep1(a) for(ll _=0;_<(ll)a;++_)
      | 
garden.cpp:26:5: error: ambiguating new declaration of 'int count_routes(int, int, int, int (*)[2], int, int*)'
   26 | int count_routes(int n,int m,int p,int r[][2],int q,int query[]){
      |     ^~~~~~~~~~~~
In file included from garden.cpp:2:
garden.h:1:6: note: old declaration 'void count_routes(int, int, int, int (*)[2], int, int*)'
    1 | void count_routes(int N, int M, int P, int R[][2], int Q, int G[]);
      |      ^~~~~~~~~~~~
garden.cpp: In function 'int count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:8:44: error: 'rep1' was not declared in this scope
    8 | #define rep(...) overload(__VA_ARGS__,rep2,rep1,rep1)(__VA_ARGS__)
      |                                            ^~~~
garden.cpp:4:31: note: in definition of macro 'overload'
    4 | #define overload(a,b,c,d,...) d
      |                               ^
garden.cpp:30:5: note: in expansion of macro 'rep'
   30 |     rep(i,m){
      |     ^~~
garden.cpp:33:13: error: expected ';' before '{' token
   33 |     rep(i,m){
      |             ^
garden.cpp:56:13: error: expected ';' before 'if'
   56 |     rep(i,n)if(to[i+n]==-1)to[i+n]=to[i];
      |             ^~
garden.cpp:66:24: error: 'g' was not declared in this scope
   66 |             for(auto u:g[v])if(dist1[u]==-1){
      |                        ^
garden.cpp:78:24: error: 'g' was not declared in this scope
   78 |             for(auto u:g[v])if(dist2[u]==-1){
      |                        ^
garden.cpp:8:39: error: 'rep2' was not declared in this scope
    8 | #define rep(...) overload(__VA_ARGS__,rep2,rep1,rep1)(__VA_ARGS__)
      |                                       ^~~~
garden.cpp:4:31: note: in definition of macro 'overload'
    4 | #define overload(a,b,c,d,...) d
      |                               ^
garden.cpp:87:9: note: in expansion of macro 'rep'
   87 |         rep(i,1,2*n+1){
      |         ^~~
garden.cpp:86:13: warning: unused variable 'now' [-Wunused-variable]
   86 |         int now=p;
      |             ^~~
garden.cpp:8:39: error: 'rep2' was not declared in this scope
    8 | #define rep(...) overload(__VA_ARGS__,rep2,rep1,rep1)(__VA_ARGS__)
      |                                       ^~~~
garden.cpp:4:31: note: in definition of macro 'overload'
    4 | #define overload(a,b,c,d,...) d
      |                               ^
garden.cpp:97:9: note: in expansion of macro 'rep'
   97 |         rep(i,1,2*n+1){
      |         ^~~
garden.cpp:96:13: warning: unused variable 'now' [-Wunused-variable]
   96 |         int now=p+n;
      |             ^~~
garden.cpp:105:13: error: expected ';' before '{' token
  105 |     rep(i,q){
      |             ^
garden.cpp:84:9: warning: unused variable 'cycle1' [-Wunused-variable]
   84 |     int cycle1=1e9,cycle2=1e9;
      |         ^~~~~~
garden.cpp:84:20: warning: unused variable 'cycle2' [-Wunused-variable]
   84 |     int cycle1=1e9,cycle2=1e9;
      |                    ^~~~~~
garden.cpp:114:1: warning: no return statement in function returning non-void [-Wreturn-type]
  114 | }
      | ^