Submission #992318

# Submission time Handle Problem Language Result Execution time Memory
992318 2024-06-04T09:13:42 Z MarwenElarbi Vision Program (IOI19_vision) C++17
Compilation error
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
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
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;
set<pair<int,int>> st;
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;
            st.insert({min(a*m+b,x*m+y),max(a*m+b,x*m+y)});
        }
        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;*/
        }
    }
    vector<pair<int,int>> tab;
    for(auto u:st){
        tab.pb(u);
    }
    shuffle(tab.begin(),tab.end(),rng);
    for (int i = 0; i < tab.size(); ++i)
    {
        add_and({u.fi,u.se});
        res.pb(cur);
        cur++;
        if(cur-W*H==9999) break;
    }
    add_or(res);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (int i = 0; i < tab.size(); ++i)
      |                     ~~^~~~~~~~~~~~
vision.cpp:80:18: error: 'u' was not declared in this scope
   80 |         add_and({u.fi,u.se});
      |                  ^
vision.cpp:80:28: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   80 |         add_and({u.fi,u.se});
      |                            ^
      |                            |
      |                            <brace-enclosed initializer list>