답안 #17765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17765 2016-01-12T10:14:45 Z Adilkhan 힘 센 거북 (IZhO11_turtle) C++
35 / 100
155 ms 86488 KB
#include <bits/stdc++.h>

#define pb push_back
#define endl "\n"
#define mp make_pair 
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())

typedef long long ll;

using namespace std;

const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;

int n, m, a[1000][1000], d[1000][1000][22], z, k, t, x, y, sum; 

int main () {
	//freopen(fname".in", "r", stdin);
	//freopen(fname".out", "w", stdout);
	scanf("%d%d%d%d%d", &n, &m, &k, &t, &z);
	if (n > 1000 && m > 1000) {
		assert(0);
	}
	for (int i = 1; i <= k; ++i) {
	  scanf("%d%d", &x, &y);
		a[x][y] = 1;
	}
	d[0][0][0] = 1;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (i == 0 && j == 0) continue;
			if (a[i][j] == 1) {
				for (int q = 1; q <= k; ++q) {
				 	if (i != 0)
						d[i][j][q] += d[i - 1][j][q - 1];
					if (j != 0)
						d[i][j][q] += d[i][j - 1][q - 1];
					d[i][j][q] %= z;
				}
			}else {
				for (int q = 0; q <= k; ++q) {
				  if (i != 0)
						d[i][j][q] += d[i - 1][j][q];
					if (j != 0)
						d[i][j][q] += d[i][j - 1][q];
					d[i][j][q] %= z;				
				}
			}	
		}
	}
	for (int i = 0; i <= t; ++i) {
		sum += d[n][m][i];
		sum %= z;
	} 
	printf("%d", sum);
	return 0;
}

Compilation message

turtle.cpp: In function 'int main()':
turtle.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d%d", &n, &m, &k, &t, &z);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
turtle.cpp:31:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d", &x, &y);
    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 1 ms 1188 KB Output is correct
5 Correct 9 ms 3676 KB Output is correct
6 Correct 43 ms 24056 KB Output is correct
7 Correct 78 ms 38160 KB Output is correct
8 Incorrect 155 ms 86488 KB Output isn't correct
9 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 7 ms 500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 1 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 7 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 7 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 9 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 7 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)