Submission #599266

#TimeUsernameProblemLanguageResultExecution timeMemory
599266jmyszka2007Furniture (JOI20_furniture)C++17
5 / 100
5068 ms10144 KiB
#include <bits/stdc++.h>
using namespace std;
int vis[1010][1010];
int meb[1010][1010];
int n, m;
void dfs(int x, int y) {
	if(x > n || y > m || vis[x][y]) {
		return;
	}
	vis[x][y] = 1;
	dfs(x + 1, y);
	dfs(x, y + 1);
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			scanf("%d", &meb[i][j]);
		}
	}
	int t;
	scanf("%d", &t);
	while(t--) {
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= m; j++) {
				vis[i][j] = meb[i][j];
			}
		}
		int a, b;
		scanf("%d%d", &a, &b);
		vis[a][b] = 1;
		dfs(1, 1);
		if(vis[n][m]) {
			printf("%d\n", 1);
			meb[a][b] = 1;
		}
		else {
			printf("%d\n", 0);
		}
	}
}
 

Compilation message (stderr)

furniture.cpp: In function 'int main()':
furniture.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
furniture.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d", &meb[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~~~
furniture.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
furniture.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...