10769 | 2024-04-11 16:06:54 | Kristóf | Ütős helyzet (75 pont) | cpp17 | Compilation error |
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int kiir(vector<int> t[8][8])
{
for(int i=0;i<8;i++)
{
for(int m=0;m<8;m++)
{
for(int k=0;k<t[i][m].size();k++)
{
cout<<t[i][m][k]<<" ";
}
cout<<"\t";
}
cout<<endl;
}
return 1;
}
struct key{
int sor;
int oszlop;
}typedef key;
bool operator<(const key& l, const key& r) {
return (l.sor<r.sor || (l.sor==r.sor && l.oszlop<r.oszlop));
}
int main()
{
vector<int> tabla[8][8];
for(int i=0;i<8;i++){
for(int m=0;m<8;m++){
tabla[i][m].push_back(0);
}
}
map<key,int>index;
int x;
int y;
int tipus;
int n;
cin>>n;
int i;
bool tores=false;
key ind;
int j;
int seged;
while(n--)
{
tores=false;
cin>>tipus>>x>>y;
y--;
x--;
//kiir(tabla);
if(tipus==1)
{
for( i=0;i<tabla[x][y].size();i++)
{
if(tabla[x][y][i]!=0)
{
break;
}
}
if(tabla[x][y][i]==0)
{
for(i=0;i<8;i++)
{
if(tores==true)
{
break;
}
for(int m=0;m<tabla[i][y].size();m++)
{
if(tabla[i][y][m]==1 || tabla[i][y][m]==2)
{
tores=true;
break;
}
}
if(tores==false)
{
ind.sor=x;
ind.oszlop=y;
tabla[x][y].push_back(1);
for(i=0;i<8;i++)
{
if(tabla[i][y][1]!=1)
{
tabla[i][y].push_back(n*10);
}
}
for(i=0;i<8;i++)
{
if(tabla[x][i][1]!=1)
{
tabla[x][i].push_back(n*10);
}
}
index[ind]=n*10;
cout<<"IGEN";
}
else
{
cout<<"NEM";
}
}
}
else
{
cout<<"NEM";
}
}
if(tipus==2)
{
for(int i=0;i<8;i++)
{
if(tores==true)
{
break;
}
if(tabla[i][y].size()>1)
{
if(tabla[i][y][1]==1 || tabla[i][y][1]==2)
{
cout<<"NEM";
tores=true;
}
}
}
for(int i=0;i<8;i++)
{
if(tores==true)
{
break;
}
if(tabla[x][i].size()>1)
{
if(tabla[x][i][1]==1 || tabla[x][i][1]==2)
{
cout<<"NEM";
tores=true;
}
}
}
j=y;
for(i=x;i>=0 && j>=0;i--)
{
if(tores==true){
break;
}
if(tabla[i][j].size()>1)
{
if(tabla[i][j][1]==1 || tabla[i][j][1]==2)
{
tores=true;
cout<<"NEM"<<endl;
}
}
j--;
}
j=y;
for(i=x;i>=0 && j<=7;i-- )
{
if(tores==true){
break;
}
if(tabla[i][j].size()>1)
{
if(tabla[i][j][1]==1 || tabla[i][j][1]==2)
{
tores=true;
cout<<"NEM"<<endl;
}
}
j++;
}
j=y;
for(i=x;i<=7 && j>=0;i++)
{
if(tores==true){
break;
}
if(tabla[i][j].size()>1)
{
if(tabla[i][j][1]==1 || tabla[i][j][1]==2)
{
tores=true;
cout<<"NEM"<<endl;
}
}
j--;
}
j=y;
for(i=x;i<=7 && j<=7;i++)
{
if(tores==true){
break;
}
if(tabla[i][j].size()>1)
{
if(tabla[i][j][1]==1 || tabla[i][j][1]==2)
{
tores=true;
cout<<"NEM"<<endl;
}
}
j++;
}
if(tores==false)
{
cout<<"IGEN"<<endl;
ind.sor=x;
ind.oszlop=y;
index[ind]=n*10;
tabla[x][y].push_back(2);
}
for(int i=0;i<8;i++)
{
if(tores==true)
{
break;
}
tabla[i][y].push_back(n*10);
}
for(int i=0;i<8;i++)
{
if(tores==true)
{
break;
}
tabla[x][i].push_back(n*10);
}
j=y;
for(i=x;i>=0 && j>=0;i-- )
{
if(tores==true){
break;
}
tabla[i][j].push_back(n*10);
j--;
}
j=y;
for(i=x;i>=0 && j<=7;i-- )
{
if(tores==true){
break;
}
tabla[i][j].push_back(n*10);
j++;
}
j=y;
for(i=x;i<=7 && j>=0;i++ )
{
if(tores==true){
break;
}
tabla[i][j].push_back(n*10);
j--;
}
j=y;
for(i=x;i<=7 && j<=7;i++)
{
if(tores==true){
break;
}
tabla[i][j].push_back(n*10);
j++;
}
}
if(tipus==3)
{
cout<<"-";
tabla[x][y]=remove(tabla[x][y].begin(),tabla[x][y].end(),2);
tabla[x][y]=remove(tabla[x][y].begin(),tabla[x][y].end(),1);
ind.sor=x;
ind.oszlop=y;
seged=index[ind];
for(i=0;i<8;i++)
{
for(int l=0;l<8;l++)
{
tabla[i][l]=remove(tabla[i][l].begin(),tabla[i][l].end(),seged);
}
}
}
kiir(tabla);
}
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:285:71: error: no match for 'operator=' (operand types are 'std::vector<int>' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
285 | tabla[x][y]=remove(tabla[x][y].begin(),tabla[x][y].end(),2);
| ^
In file included from /usr/include/c++/11/vector:72,
from main.cpp:2:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
198 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'const std::vector<int>&'
199 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c+...