Submission #601307

# Submission time Handle Problem Language Result Execution time Memory
601307 2022-07-21T16:21:54 Z ignus Furniture (JOI20_furniture) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a[n][m];
	int up[n][m];
	int left[n][m];
	bool checked[n][m];
	up[0][0]=1;
	left[0][0]=1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			checked[i][j]=0;
			left[i][j]=0;
			up[i][j]=0;
			bool temp;
			cin >> temp;
			a[i][j]=!temp;
		}
	}
	queue<pair<int, int>> q;
	q.push({0,0});
	while(!q.empty()){
		int x=q.front().second, y=q.front().first;
		if(a[y][x+1]){
			if(!up[y][x+1]){
				q.push({y, x+1});
			}
			left[y][x+1]=1;
		}
		if(a[y+1][x]){
			if(!left[y+1][x]){
				q.push({y+1, x});
			}
			up[y+1][x]=1;
		}
		q.pop();
	}
	checked[n-1][m-1]=1;
	int qe;
	cin >> qe;
	for(int i = 0; i < qe; i++){
		queue<pair<int, pair<int, int>>> forgor;
		int x, y;
		cin >> y >> x;
		if(a[y-1][x-1]){
			cout << "1\n";
			continue;
		}
		queue<pair<int, int>> qu;
		qu.push({y-1, x-1});
		while(!qu.empty()){
			int y1 = qu.front().first, x1=qu.front().second;
			//cout << y1 << '-' << x1<< ',';
			if(checked[y1][x1]){
				checked[y][x]=1;
				while(!forgor.empty()){
					int type=forgor.front().first;
					int y2=forgor.front().second.first;
					int x2=forgor.front().second.second;
					if(type==0) a[y2][x2]=1;
					if(type==1) left[y2][x2]=1;
					if(type==2) up[y2][x2]=1;
					forgor.pop();
				}
				cout << "0\n";
				goto ende;
			}
			a[y1][x1]=0;
			forgor.push({0, {y1, x1}});
			qu.pop();
		//	cout << x1 << ' ' << a[y1][x1+1] << ' ' << !up[y1][x1+1] << ' '<<left[y1][x1+1] << ',';
			if(x1<m-1&&a[y1][x1+1]){
				if(!up[y1][x1+1]&&left[y1][x1+1]){
					qu.push({y1, x1+1});
				}
				left[y1][x1+1]=0;
				forgor.push({1, {y1, x1+1}});
			}
			if(y1<n-1&&a[y1+1][x1]){
				if(!left[y1+1][x1]&&up[y1+1][x1]){
					qu.push({y1+1, x1});
				}
				up[y1+1][x1]=0;
				forgor.push({2, {y1+1, x1}});
			}
	/*	} 
		cout << '\n';
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cout << a[i][j] <<  left[i][j] <<up[i][j] <<' ';
			}
			cout << '\n';
		}*/
		cout << "1\n";
		ende:
		continue;
	}
/*	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << a[i][j] <<  left[i][j] <<up[i][j] <<' ';
		}
		cout << '\n';
	}*/
	return 0;
}

Compilation message

furniture.cpp: In function 'int main()':
furniture.cpp:108:1: error: expected '}' at end of input
  108 | }
      | ^
furniture.cpp:4:11: note: to match this '{'
    4 | int main(){
      |           ^