답안 #1069549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069549 2024-08-22T05:28:09 Z 김은성(#11131) Passport (JOI23_passport) C++17
16 / 100
2000 ms 50528 KB
#include <bits/stdc++.h>
using namespace std;
const int INF = 1.557e8;
int dp[2509][2509], l[2509], r[2509];
int main(){
	int n, q, t, i, j, k, x;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%d %d", &l[i], &r[i]);
	}
	scanf("%d", &q);
	while(q--){
		scanf("%d", &x);
		for(i=1; i<=n; i++){
			for(j=i; j<=n; j++){
				dp[i][j] = INF;
			}
		}
		dp[x][x] = 0;
		for(t=0; t<n; t++){
			for(i=1; i+t<=n; i++){
				j = i+t;
				if(dp[i][j] >= INF/2)
					continue;
				for(k=i; k<=j; k++){
					int ti = min(i, l[k]), tj = max(j, r[k]);
					dp[ti][tj] = min(dp[i][j] + 1, dp[ti][tj]);
				}
			}
		}
		if(dp[1][n] >= INF/2)
			dp[1][n] = -1;
		printf("%d\n", dp[1][n]);
	}
	return 0;
}

Compilation message

passport.cpp: In function 'int main()':
passport.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
passport.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d %d", &l[i], &r[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
passport.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
passport.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 208 ms 50528 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 3 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 3 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
16 Correct 1620 ms 19036 KB Output is correct
17 Correct 886 ms 20568 KB Output is correct
18 Correct 27 ms 20568 KB Output is correct
19 Correct 41 ms 20056 KB Output is correct
20 Execution timed out 2056 ms 20568 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 3 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 3 ms 1628 KB Output is correct
16 Correct 1620 ms 19036 KB Output is correct
17 Correct 886 ms 20568 KB Output is correct
18 Correct 27 ms 20568 KB Output is correct
19 Correct 41 ms 20056 KB Output is correct
20 Execution timed out 2056 ms 20568 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 208 ms 50528 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -