#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:77:39: error: expected ';' before 'for'
77 | shuffle(tab.begin(),tab.end(),rng)
| ^
| ;
78 | for (int i = 0; i < tab.size(); ++i)
| ~~~
vision.cpp:78:21: error: 'i' was not declared in this scope
78 | for (int i = 0; i < tab.size(); ++i)
| ^