Submission #473037

# Submission time Handle Problem Language Result Execution time Memory
473037 2021-09-14T19:00:45 Z rainboy Planinarenje (COCI18_planinarenje) C
48 / 160
7 ms 1096 KB
#include <stdio.h>

#define N	10

int dp[1 << N + N][N + N], n; char adj[N + N][N + N], visited[1 << N + N][N + N];

int dfs(int b, int i) {
	if (!visited[b][i]) {
		int j;

		visited[b][i] = 1;
		for (j = 0; j < n + n; j++)
			if (adj[i][j] && (b & 1 << j) == 0 && !dfs(b | 1 << j, j)) {
				dp[b][i] = 1;
				break;
			}
	}
	return dp[b][i];
}

int main() {
	int m, i, j;

	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d%d", &i, &j), i--, j--;
		adj[i][n + j] = adj[n + j][i] = 1;
	}
	for (i = 0; i < n; i++)
		printf(dfs(1 << i, i) ? "Slavko\n" : "Mirko\n");
	return 0;
}

Compilation message

planinarenje.c:5:10: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    5 | int dp[1 << N + N][N + N], n; char adj[N + N][N + N], visited[1 << N + N][N + N];
      |          ^~
planinarenje.c:5:65: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    5 | int dp[1 << N + N][N + N], n; char adj[N + N][N + N], visited[1 << N + N][N + N];
      |                                                                 ^~
planinarenje.c: In function 'main':
planinarenje.c:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
planinarenje.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1096 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 644 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -