답안 #992308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992308 2024-06-04T09:07:14 Z MarwenElarbi Vision Program (IOI19_vision) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "vision.h"

using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back

int arx[4]={1,-1,0,0};
int ary[4]={0,0,1,-1};
int n,m,k;
int dp[31][31];
int cur;
vector<int> res;
int arx[4]={1,-1,0,0};
int ary[4]={0,0,1,-1};
int n,m,k;
int dp[31][31];
int cur;
vector<int> res;
bool valid(int x,int y){
    if(x<0||x>=n||y<0||y>=m) return false;
    return true;
}
void dfs(int x,int y,int a,int b){
    queue<pair<int,int>> q;
    q.push({x,y});
    while(!q.empty()){
        int x=q.front().fi;
        int y=q.front().se;
        q.pop();
        if(dp[x][y]==k){
            //cout <<dp[x][y]<<" "<<a<<" "<<b<<" "<<x<<" "<<y<<endl;
            add_and({a*m+b,x*m+y});
            res.pb(cur);
            cur++;
        }
        for (int i = 0; i < 4; ++i)
        {
            int curx=x+arx[i];
            int cury=y+ary[i];
            if(valid(curx,cury)){
                //cout <<"hey"<<endl;
                if(dp[curx][cury]<=dp[x][y]+1) continue;
                dp[curx][cury]=dp[x][y]+1;
                q.push({curx,cury});
            }
        }
    }
    
}
void construct_network(int H, int W, int K) {
    n=H;
    m=W;
    k=K;
    cur=n*m;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            for (int k = 0; k < n; ++k)
            {
                for (int t = 0; t < m; ++t)
                {
                    dp[k][t]=1e9;
                }
            }
            dp[i][j]=0;
            dfs(i,j,i,j);
            /*for (int k = 0; k < n; ++k)
            {
                for (int t = 0; t < m; ++t)
                {
                    cout << dp[k][t]<<" ";
                }cout <<endl;
            }cout <<endl;*/
        }
    }
    add_or(res);
}

Compilation message

vision.cpp:16:5: error: redefinition of 'int arx [4]'
   16 | int arx[4]={1,-1,0,0};
      |     ^~~
vision.cpp:10:5: note: 'int arx [4]' previously defined here
   10 | int arx[4]={1,-1,0,0};
      |     ^~~
vision.cpp:17:5: error: redefinition of 'int ary [4]'
   17 | int ary[4]={0,0,1,-1};
      |     ^~~
vision.cpp:11:5: note: 'int ary [4]' previously defined here
   11 | int ary[4]={0,0,1,-1};
      |     ^~~
vision.cpp:18:5: error: redefinition of 'int n'
   18 | int n,m,k;
      |     ^
vision.cpp:12:5: note: 'int n' previously declared here
   12 | int n,m,k;
      |     ^
vision.cpp:18:7: error: redefinition of 'int m'
   18 | int n,m,k;
      |       ^
vision.cpp:12:7: note: 'int m' previously declared here
   12 | int n,m,k;
      |       ^
vision.cpp:18:9: error: redefinition of 'int k'
   18 | int n,m,k;
      |         ^
vision.cpp:12:9: note: 'int k' previously declared here
   12 | int n,m,k;
      |         ^
vision.cpp:19:5: error: redefinition of 'int dp [31][31]'
   19 | int dp[31][31];
      |     ^~
vision.cpp:13:5: note: 'int dp [31][31]' previously declared here
   13 | int dp[31][31];
      |     ^~
vision.cpp:20:5: error: redefinition of 'int cur'
   20 | int cur;
      |     ^~~
vision.cpp:14:5: note: 'int cur' previously declared here
   14 | int cur;
      |     ^~~
vision.cpp:21:13: error: redefinition of 'std::vector<int> res'
   21 | vector<int> res;
      |             ^~~
vision.cpp:15:13: note: 'std::vector<int> res' previously declared here
   15 | vector<int> res;
      |             ^~~