답안 #676140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676140 2022-12-29T12:53:54 Z coding_snorlax 늑대인간 (IOI18_werewolf) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
vector<int> G[200002];
int vis1[3002]={0};
int vis2[3002]={0};
#include<bits/stdc++.h>
using namespace std;
int seg_Max[800008];
int seg_Min[800008];
int query_min(int L,int R,int qL,int qR,int id){
    cout << L <<" " << R <<" "<<qL<<" "<<qR<<" "<<id<<"\n";
    if(L==qL && R==qR) return seg_Min[id];
    int M = (L+R)/2;
    if(qL>M) return query_min(M+1,R,qL,qR,2*id+1);
    else if(qR<=M) return query_min(L,M,qL,qR,2*id);
    else return min(query_min(L,M,qL,M,2*id),query_min(M+1,R,M+1,qR,2*id+1));
}
void modify_min(int L,int R,int num,int node,int id){
    cout<<L<<" "<<R<<" "<<num<<" "<<node<<" "<<id<<"\n";
    if(L==R){
        seg_Min[id] = num;
        return;
    }
    int M = (L+R)/2;
    if(node<=M) modify_min(L,M,num,node,2*id);
    else modify_min(M+1,R,num,node,2*id+1);
    seg_Min[id] = min(seg_Min[2*id],seg_Min[2*id+1]);
    cout<<"seg: "<<seg_Min[id]<<"\n";
}
int query_max(int L,int R,int qL,int qR,int id){
    if(L==qL && R==qR) return seg_Max[id];
    int M = (L+R)/2;
    if(qL>M) return query_max(M+1,R,qL,qR,2*id+1);
    else if(qR<=M) return query_max(L,M,qL,qR,2*id);
    else return max(query_max(L,M,qL,M,2*id),query_max(M+1,R,M+1,qR,2*id+1));
}
void modify_max(int L,int R,int num,int node,int id){
    if(L==R) seg_Max[id] = num;
    int M = (L+R)/2;
    if(node<=M) modify_max(L,M,num,node,2*id);
    else modify_max(M+1,R,num,node,2*id+1);
    seg_Max[id] = max(seg_Max[2*id],seg_Max[2*id+1]);
}
int main(){
    for(int i=0;i<800008;i++){
        seg_Max[i]=0;
    }
    for(int i=0;i<800008;i++){
        seg_Min[i]=800008;
    }
    modify_min(0,10,5,1,1);
    modify_min(0,10,6,2,1);
    for(int i=0;i<32;i++) cout<<seg_Min[i]<<" ";
    cout<<query_min(0,10,2,4,1);
}

int dfs_L(int node,int Left_bound){
    vis1[node]=1;
    for(int i:G[node]) {if(!vis1[i] && i>=Left_bound) dfs_L(i,Left_bound);};
}
int dfs_R(int node,int Right_bound){
    vis2[node]=1;
    for(int i:G[node]) {if(!vis2[i] && i<=Right_bound) dfs_R(i,Right_bound);};
}
vector<int> check_validity(int N,vector<int> X,vector<int> Y,vector<int> S,vector<int> E,vector<int> L,vector<int> R){
    vector<int> answer;
    for(int i=0;i<(int)X.size();i++){G[X[i]].push_back(Y[i]);G[Y[i]].push_back(X[i]);}
    for(int i=0;i<(int)S.size();i++){
        for(int j=0;j<N;j++) vis1[j]=0;
        dfs_L(S[i],L[i]);
        for(int j=0;j<N;j++) vis2[j]=0;
        dfs_R(E[i],R[i]);
        int flag=0;
        for(int i=0;i<N;i++){
            if(vis1[i]&&vis2[i]) flag=1;
        }
        if(flag) answer.push_back(1);
        else answer.push_back(0);
    }
    return answer;
}
int main(){
    int N=6;vector<int> X={5,1,1,3,3,5},Y={1,2,3,4,0,2},S={4,4,5},E={2,2,4},L={1,2,3},R={2,2,4};
    vector<int> answer = check_validity(N,X,Y,S,E,L,R);
    for(int i:answer) cout<<i<<" ";
}

Compilation message

werewolf.cpp: In function 'int dfs_L(int, int)':
werewolf.cpp:60:1: warning: no return statement in function returning non-void [-Wreturn-type]
   60 | }
      | ^
werewolf.cpp: In function 'int dfs_R(int, int)':
werewolf.cpp:64:1: warning: no return statement in function returning non-void [-Wreturn-type]
   64 | }
      | ^
werewolf.cpp: At global scope:
werewolf.cpp:82:5: error: redefinition of 'int main()'
   82 | int main(){
      |     ^~~~
werewolf.cpp:44:5: note: 'int main()' previously defined here
   44 | int main(){
      |     ^~~~