Submission #1155236

#TimeUsernameProblemLanguageResultExecution timeMemory
1155236KhoaDuyAmusement Park (JOI17_amusement_park)C++20
Compilation error
0 ms0 KiB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int MAXN=10000;
int dsu[MAXN];
int in[MAXN];
int tim=0;
vector<vector<int>> graph;
int pa[MAXN];
int Findset(int i){
    if(dsu[i]<0){
        return i;
    }
    int root=Findset(dsu[i]);
    dsu[i]=root;
    return root;
}
void unite(int u,int v){
    u=Findset(u),v=Findset(v);
    if(u==v){
        return;
    }
    if(dsu[u]<dsu[v]){
        swap(u,v);
    }
    dsu[v]+=dsu[u];
    dsu[u]=v;
}
void setup(int u,int p){
    pa[u]=p;
    in[u]=tim;
    tim++;
    for(int v:graph[u]){
        if(v!=p){
            setup(v,u);
        }
    }
}
void buildtree(int a[],int b[],int n,int m){
    graph.clear();
    graph.resize(n);
    tim=0;
    for(int i=0;i<n;i++){
        dsu[i]=-1,in[i]=0,pa[i]=0;
    }
    for(int i=0;i<m;i++){
        if(Findset(a[i])!=Findset(b[i])){
            unite(a[i],b[i]);
            graph[a[i]].push_back(b[i]);
            graph[b[i]].push_back(a[i]);
        }
    }
    setup(0,-1);
}
void Joi(int n,int m,int a[],int b[],long long x,int t){
    buildtree(a,b,n,m);
    for(int i=0;i<n;i++){
        int bit=(x&(1LL<<(in[i]%60)));
        bit>>=(in[i]%60);
        MessageBoard(i,bit);
    }
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int MAXN=10000;
int dsu[MAXN];
int in[MAXN];
int tim=0;
vector<vector<int>> graph;
int pa[MAXN];
int Findset(int i){
    if(dsu[i]<0){
        return i;
    }
    int root=Findset(dsu[i]);
    dsu[i]=root;
    return root;
}
void unite(int u,int v){
    u=Findset(u),v=Findset(v);
    if(u==v){
        return;
    }
    if(dsu[u]<dsu[v]){
        swap(u,v);
    }
    dsu[v]+=dsu[u];
    dsu[u]=v;
}
void setup(int u,int p){
    pa[u]=p;
    in[u]=tim;
    tim++;
    for(int v:graph[u]){
        if(v!=p){
            setup(v,u);
        }
    }
}
void buildtree(int a[],int b[],int n,int m){
    graph.clear();
    graph.resize(n);
    tim=0;
    for(int i=0;i<n;i++){
        dsu[i]=-1,in[i]=0,pa[i]=0;
    }
    for(int i=0;i<m;i++){
        if(Findset(a[i])!=Findset(b[i])){
            unite(a[i],b[i]);
            graph[a[i]].push_back(b[i]);
            graph[b[i]].push_back(a[i]);
        }
    }
    setup(0,-1);
}
long long x=-1;
int val[60];
int write[MAXN];
void update(int k,int bit){
    val[k]=bit;
    bool flag=true;
    for(int i=0;i<60;i++){
        if(val[i]==-1){
            flag=false;
            break;
        }
    }
    if(flag){
        x=0;
        for(int i=0;i<60;i++){
            if(val[i]){
                x^=(1LL<<i);
            }
        }
    }
}
void DFS(int u,int p,char dir){
    update(in[u]%60,write[u]);
    if(x!=-1){
        return;
    }
    if(dir=='R'){
        for(int i=(int)graph[u].size()-1;i>=0;i--){
            int v=graph[u][i];
            if(v!=p){
                write[v]=Move(v);
                DFS(v,u,dir);
                if(x!=-1){
                    return;
                }
                write[u]=Move(u);
            }
        }
    }
    else{
        for(int v:graph[u]){
            if(v!=p){
                write[v]=Move(v);
                DFS(v,u,dir);
                if(x!=-1){
                    return;
                }
                write[u]=Move(u);
            }
        }
    }
}
long long Ioi(int n,int m,int a[],int b[],int u,int V,int t){
    memset(val,-1,sizeof(val));
    buildtree(a,b,n,m);
    write[u]=V;
    int last=-1;
    while(x==-1&&u!=-1){
        update(in[u]%60,write[u]);
        if(x!=-1){
            return x;
        }
        int pos=-1;
        for(int i=0;i<graph[u].size();i++){
            int v=graph[u][i];
            if(v!=pa[u]&&v==last){
                pos=i;
                break;
            }
        }
        for(int i=pos-1;i>=0;i--){
            int v=graph[u][i];
            if(v!=pa[u]){
                write[v]=Move(v);
                DFS(v,u,'R');
                write[u]=Move(u);
                if(x!=-1){
                    return x;
                }
            }
        }
        for(int i=pos+1;i<graph[u].size();i++){
            int v=graph[u][i];
            if(v!=pa[u]){
                write[v]=Move(v);
                DFS(v,u,'L');
                write[u]=Move(u);
                if(x!=-1){
                    return x;
                }
            }
        }
        u=pa[u];
        if(u!=-1){
            write[u]=Move(u);
        }
    }
    return x;
}

Compilation message (stderr)

# 2번째 컴파일 단계

Ioi.cpp:58:15: error: 'int write [10000]' redeclared as different kind of entity
   58 | int write[MAXN];
      |               ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from Ioi.cpp:2:
/usr/include/unistd.h:378:16: note: previous declaration 'ssize_t write(int, const void*, size_t)'
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~
Ioi.cpp: In function 'void DFS(int, int, char)':
Ioi.cpp:78:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   78 |     update(in[u]%60,write[u]);
      |                            ^
Ioi.cpp:78:28: error: invalid conversion from 'ssize_t (*)(int, const void*, size_t)' {aka 'long int (*)(int, const void*, long unsigned int)'} to 'int' [-fpermissive]
   78 |     update(in[u]%60,write[u]);
      |                     ~~~~~~~^
      |                            |
      |                            ssize_t (*)(int, const void*, size_t) {aka long int (*)(int, const void*, long unsigned int)}
Ioi.cpp:59:23: note:   initializing argument 2 of 'void update(int, int)'
   59 | void update(int k,int bit){
      |                   ~~~~^~~
Ioi.cpp:86:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   86 |                 write[v]=Move(v);
      |                        ^
Ioi.cpp:86:25: error: assignment of read-only location '*(write + ((sizetype)v))'
   86 |                 write[v]=Move(v);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:91:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   91 |                 write[u]=Move(u);
      |                        ^
Ioi.cpp:91:25: error: assignment of read-only location '*(write + ((sizetype)u))'
   91 |                 write[u]=Move(u);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:98:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   98 |                 write[v]=Move(v);
      |                        ^
Ioi.cpp:98:25: error: assignment of read-only location '*(write + ((sizetype)v))'
   98 |                 write[v]=Move(v);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:103:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  103 |                 write[u]=Move(u);
      |                        ^
Ioi.cpp:103:25: error: assignment of read-only location '*(write + ((sizetype)u))'
  103 |                 write[u]=Move(u);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:111:12: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  111 |     write[u]=V;
      |            ^
Ioi.cpp:111:13: error: assignment of read-only location '*(write + ((sizetype)u))'
  111 |     write[u]=V;
      |     ~~~~~~~~^~
Ioi.cpp:114:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  114 |         update(in[u]%60,write[u]);
      |                                ^
Ioi.cpp:114:32: error: invalid conversion from 'ssize_t (*)(int, const void*, size_t)' {aka 'long int (*)(int, const void*, long unsigned int)'} to 'int' [-fpermissive]
  114 |         update(in[u]%60,write[u]);
      |                         ~~~~~~~^
      |                                |
      |                                ssize_t (*)(int, const void*, size_t) {aka long int (*)(int, const void*, long unsigned int)}
Ioi.cpp:59:23: note:   initializing argument 2 of 'void update(int, int)'
   59 | void update(int k,int bit){
      |                   ~~~~^~~
Ioi.cpp:129:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  129 |                 write[v]=Move(v);
      |                        ^
Ioi.cpp:129:25: error: assignment of read-only location '*(write + ((sizetype)v))'
  129 |                 write[v]=Move(v);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:131:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  131 |                 write[u]=Move(u);
      |                        ^
Ioi.cpp:131:25: error: assignment of read-only location '*(write + ((sizetype)u))'
  131 |                 write[u]=Move(u);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:140:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  140 |                 write[v]=Move(v);
      |                        ^
Ioi.cpp:140:25: error: assignment of read-only location '*(write + ((sizetype)v))'
  140 |                 write[v]=Move(v);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:142:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  142 |                 write[u]=Move(u);
      |                        ^
Ioi.cpp:142:25: error: assignment of read-only location '*(write + ((sizetype)u))'
  142 |                 write[u]=Move(u);
      |                 ~~~~~~~~^~~~~~~~
Ioi.cpp:150:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  150 |             write[u]=Move(u);
      |                    ^
Ioi.cpp:150:21: error: assignment of read-only location '*(write + ((sizetype)u))'
  150 |             write[u]=Move(u);
      |             ~~~~~~~~^~~~~~~~