828 | 2022-01-18 21:43:28 | Halasz Eszter | Ciklikus rácsháló gráf | cpp11 | Forditási hiba |
#include <iostream>
//#include <fstream>
#include <algorithm>
#include <deque>
using namespace std;
//ifstream cin("ciklikusracshalograf.in");
//ofstream cout("ciklikusracshalograf.out");
deque<int>y;
struct adat
{
int x,y;
};
adat a,b,q;
struct adat2
{
int lat,lep;
vector<int>sz;
};
vector<adat2>x;
int i,j,n,m,k,maxii=-9999,aa,bb;
void maxi(int a)
{
int i;
for(i=1;i<=n*m;++i)
if(x[i].lep>maxii) maxii=x[i].lep;
for(i=1;i<=n*m;++i)
{
x[i].lat=0;
}
}
void szelessegi(int i)
{
int csp=0;
y.push_back(i);
x[i].lep=0;
while(!y.empty())
{
csp=y.front();
y.pop_front();
for(auto e:x[csp].sz)
{
if(x[e].lat==0)
{
x[e].lat=1;
x[e].lep=x[csp].lep+1;
y.push_back(e);
}
else x[e].lep=min(x[e].lep,x[csp].lep+1);
}
}
}
int main()
{
cin>>n>>m>>k;
x.resize(n*m+1);
for(i=1;i<=n*m;++i)
{
for(j=1;j<=n*m;++j)
if(j>i)
{
if(i%m!=0) a.x=i/m+1;
else a.x=i/m;
if(j%m!=0) b.x=j/m+1;
else b.x=j/m;
a.y=i%m;
if(a.y==0) a.y=m;
b.y=j%m;
if(b.y==0) b.y=m;
if((a.y==1 && b.y==m && b.x==a.x) || (a.y==b.y && a.x==1 && b.x==n) || (abs(a.x-b.x)+abs(a.y-b.y)==1))
{
x[i].sz.push_back(j);
x[j].sz.push_back(i);
}
}
}
while(k)
{
cin>>aa>>bb;
x[aa].sz.push_back(bb);
x[bb].sz.push_back(aa);
maxii=-9999;
for(i=1;i<=n*m;++i)
{
szelessegi(i);
maxi(aa);
}
cout<<maxii<<"\n";
k--;
}
return 0;
}
exit status 1main.cpp:22:5: error: ‘vector’ does not name a type
22 | vector<int>sz;
| ^~~~~~
main.cpp:24:1: error: ‘vector’ does not name a type
24 | vector<adat2>x;
| ^~~~~~
main.cpp: In function ‘void maxi(int)’:
main.cpp:32:8: error: ‘x’ was not declared in this scope
32 | if(x[i].lep>maxii) maxii=x[i].lep;
| ^
main.cpp:35:9: error: ‘x’ was not declared in this scope
35 | x[i].lat=0;
| ^
main.cpp: In function ‘void szelessegi(int)’:
main.cpp:42:5: error: ‘x’ was not declared in this scope
42 | x[i].lep=0;
| ^
main.cpp: In function ‘int main()’:
main.cpp:62:5: error: ‘x’ was not declared in this scope
62 | x.resize(n*m+1);
| ^
Exited with error status 1