답안 #110568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110568 2019-05-11T08:07:12 Z ckodser Wall (CEOI14_wall) C++14
30 / 100
957 ms 20192 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 44, K = 10;
int n, m, vert[N][N], horz[N][N], F[N][N];
ll dp[N][N][1 << K];
priority_queue < pair < ll , int > > Pq;
inline void Relax(int a, int b, int mask, ll d)
{
	if (dp[a][b][mask] > d)
	{
		dp[a][b][mask] = d;
		Pq.push(make_pair(- d, (mask << 12) | (b << 6) | a));
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	vector < pair < int , int > > vec;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			int b;
			scanf("%d", &b);
			if (b)
				vec.push_back({i, j});
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= m; j++)
			scanf("%d", &vert[i][j]);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j < m; j++)
			scanf("%d", &horz[i][j]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			for (int h = 0; h < (int)vec.size(); h++)
				if (vec[h].first >= i && vec[h].second == j)
					F[i][j] ^= 1 << h;
		}
	assert((int)vec.size() <= 10);
	memset(dp, 63, sizeof(dp)); dp[0][0][0] = 0;
	Pq.push({0, 0});
	while (Pq.size())
	{
		int d, a, b, mask, tmp;
	   	d = - Pq.top().first;
		tmp = Pq.top().second;
		a = tmp & 63; tmp >>= 6;
		b = tmp & 63; tmp >>= 6;
		mask = tmp;
		Pq.pop();
		if (d > dp[a][b][mask])
			continue;

		// Up :
		if (a > 0)
			Relax(a - 1, b, mask, d + vert[a - 1][b]);

		// Down :
		if (a < n)
			Relax(a + 1, b, mask, d + vert[a][b]);

		// Left :
		if (b > 0)
			Relax(a, b - 1, mask ^ F[a][b - 1], d + horz[a][b - 1]);

		// Right :
		if (b < m)
			Relax(a, b + 1, mask ^ F[a][b], d + horz[a][b]);
	}
	return !printf("%lld\n", dp[0][0][(1 << (int)vec.size()) - 1]);
}

Compilation message

wall.cpp: In function 'int main()':
wall.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
wall.cpp:24:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &b);
    ~~~~~^~~~~~~~~~
wall.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &vert[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~
wall.cpp:33:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &horz[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 15872 KB Output is correct
2 Correct 16 ms 15872 KB Output is correct
3 Correct 14 ms 15872 KB Output is correct
4 Correct 16 ms 15872 KB Output is correct
5 Correct 14 ms 15872 KB Output is correct
6 Correct 15 ms 15872 KB Output is correct
7 Correct 454 ms 18052 KB Output is correct
8 Correct 25 ms 16128 KB Output is correct
9 Correct 15 ms 15872 KB Output is correct
10 Correct 15 ms 15872 KB Output is correct
11 Correct 702 ms 20192 KB Output is correct
12 Correct 37 ms 15916 KB Output is correct
13 Correct 194 ms 18028 KB Output is correct
14 Correct 957 ms 20092 KB Output is correct
15 Correct 20 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 5 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 18 ms 15972 KB Output is correct
5 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 4 ms 520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 111 ms 17036 KB Output is correct
10 Correct 21 ms 16128 KB Output is correct
11 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 791 ms 17004 KB Output is correct
15 Correct 109 ms 18036 KB Output is correct
16 Correct 16 ms 16000 KB Output is correct
17 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6 ms 256 KB Time limit exceeded (wall clock)
2 Execution timed out 6 ms 256 KB Time limit exceeded (wall clock)
3 Execution timed out 6 ms 256 KB Time limit exceeded (wall clock)
4 Execution timed out 7 ms 256 KB Time limit exceeded (wall clock)
5 Execution timed out 12 ms 768 KB Time limit exceeded (wall clock)
6 Execution timed out 7 ms 384 KB Time limit exceeded (wall clock)
7 Runtime error 11 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 16 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Execution timed out 14 ms 384 KB Time limit exceeded (wall clock)
10 Execution timed out 10 ms 256 KB Time limit exceeded (wall clock)
11 Execution timed out 12 ms 412 KB Time limit exceeded (wall clock)
12 Execution timed out 8 ms 356 KB Time limit exceeded (wall clock)
13 Execution timed out 12 ms 384 KB Time limit exceeded (wall clock)
14 Execution timed out 23 ms 384 KB Time limit exceeded (wall clock)
15 Runtime error 28 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Execution timed out 25 ms 384 KB Time limit exceeded (wall clock)
17 Execution timed out 18 ms 256 KB Time limit exceeded (wall clock)
18 Execution timed out 20 ms 356 KB Time limit exceeded (wall clock)
19 Execution timed out 16 ms 384 KB Time limit exceeded (wall clock)
20 Execution timed out 15 ms 384 KB Time limit exceeded (wall clock)