답안 #290186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290186 2020-09-03T13:17:24 Z fucking_do_it 벽 칠하기 (APIO20_paint) C++14
28 / 100
1500 ms 275904 KB
#include "paint.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf = 2e4+9,MX = 1e9+9;
int n,m,k;
int a[inf];
vector<int> Cont[inf];
int LCS[inf][2009],dp[inf];
bool valid[inf];
unordered_map<int,int> mp[2009];

bool like(int i,int j){
    return mp[j][ a[i] ];
    int idx = lower_bound(Cont[j].begin(),Cont[j].end(),a[i]) - Cont[j].begin();
    if(idx < Cont[j].size() && Cont[j][idx] == a[i])
        return 1;
    return 0;
}

int minimumInstructions(int N, int M, int K, vector<int> C,
   vector<int> A,vector<vector<int>> B) {

    n = N, m = M,k = K;
    for(int i=1;i<=n;i++)
        a[i] = C[i-1]+1;
    for(int i=1;i<=m;i++){
        for(auto o:B[i-1])
            Cont[i].push_back(o+1),mp[i][o+1] = 1;
        sort(Cont[i].begin(),Cont[i].end());
    }

    for(int i=n;i>=1;i--){
        for(int j=m;j>=1;j--){
            if(like(i,j))
                LCS[i][j] = LCS[i+1][j+1] + 1;
            else
                LCS[i][j] = 0;
        }
    }

    for(int y=1;y <= n-m+1;y++){
        for(int x = 1;x <= m;x++){
            int len1 = m-x+1,i1 = y,j1 = x,tmp1;
            tmp1 = LCS[i1][j1];

            int len2 = x-1,i2 = y+len1,j2 = 1,tmp2 = 0;
            if(len2)
                tmp2 = LCS[i2][j2];

            valid[y] |= (tmp1 >= len1 && tmp2 >= len2);
        }
    }
    for(int i=1;i<=n;i++)
        dp[i] = MX;

    dp[n-m+1] = (valid[n-m+1]?1:MX);

    for(int i=n-m;i>=1;i--)
        for(int j=i+1;j<=i+m && valid[i];j++)
            dp[i] = min(dp[i],dp[j] + 1);

    return ( (dp[1] == MX)?-1:dp[1]);
}

Compilation message

paint.cpp: In function 'bool like(int, int)':
paint.cpp:16:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if(idx < Cont[j].size() && Cont[j][idx] == a[i])
      |        ~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 896 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 896 KB Output is correct
6 Correct 1 ms 896 KB Output is correct
7 Correct 2 ms 2944 KB Output is correct
8 Correct 2 ms 2944 KB Output is correct
9 Correct 2 ms 2944 KB Output is correct
10 Correct 2 ms 2944 KB Output is correct
11 Correct 2 ms 2944 KB Output is correct
12 Correct 2 ms 2944 KB Output is correct
13 Correct 18 ms 7808 KB Output is correct
14 Correct 17 ms 7808 KB Output is correct
15 Correct 18 ms 7808 KB Output is correct
16 Correct 19 ms 7808 KB Output is correct
17 Correct 19 ms 7808 KB Output is correct
18 Correct 18 ms 7808 KB Output is correct
19 Correct 24 ms 7680 KB Output is correct
20 Correct 21 ms 7808 KB Output is correct
21 Correct 19 ms 7808 KB Output is correct
22 Correct 67 ms 13560 KB Output is correct
23 Correct 65 ms 13560 KB Output is correct
24 Correct 69 ms 13560 KB Output is correct
25 Correct 42 ms 81528 KB Output is correct
26 Correct 41 ms 81496 KB Output is correct
27 Correct 42 ms 81784 KB Output is correct
28 Correct 44 ms 81636 KB Output is correct
29 Correct 41 ms 81788 KB Output is correct
30 Correct 43 ms 81788 KB Output is correct
31 Execution timed out 1580 ms 275904 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 896 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 896 KB Output is correct
6 Correct 1 ms 896 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 896 KB Output is correct
9 Correct 2 ms 2944 KB Output is correct
10 Correct 2 ms 2944 KB Output is correct
11 Correct 2 ms 2944 KB Output is correct
12 Correct 2 ms 2944 KB Output is correct
13 Correct 2 ms 2944 KB Output is correct
14 Correct 2 ms 2944 KB Output is correct
15 Correct 18 ms 7808 KB Output is correct
16 Correct 17 ms 7808 KB Output is correct
17 Correct 18 ms 7808 KB Output is correct
18 Correct 19 ms 7808 KB Output is correct
19 Correct 19 ms 7808 KB Output is correct
20 Correct 18 ms 7808 KB Output is correct
21 Correct 24 ms 7680 KB Output is correct
22 Correct 21 ms 7808 KB Output is correct
23 Correct 19 ms 7808 KB Output is correct
24 Correct 1 ms 896 KB Output is correct
25 Correct 1 ms 896 KB Output is correct
26 Correct 1 ms 896 KB Output is correct
27 Correct 1 ms 2048 KB Output is correct
28 Correct 2 ms 2304 KB Output is correct
29 Correct 1 ms 1920 KB Output is correct
30 Correct 2 ms 2304 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 2 ms 2432 KB Output is correct
33 Correct 16 ms 6016 KB Output is correct
34 Correct 16 ms 6272 KB Output is correct
35 Correct 7 ms 3840 KB Output is correct
36 Correct 10 ms 4992 KB Output is correct
37 Correct 11 ms 4864 KB Output is correct
38 Correct 2 ms 2176 KB Output is correct
39 Correct 2 ms 2176 KB Output is correct
40 Correct 10 ms 4608 KB Output is correct
41 Correct 7 ms 3712 KB Output is correct
42 Correct 8 ms 4480 KB Output is correct
43 Correct 4 ms 2944 KB Output is correct
44 Correct 2 ms 2944 KB Output is correct
45 Correct 3 ms 3104 KB Output is correct
46 Correct 2 ms 2944 KB Output is correct
47 Correct 4 ms 3072 KB Output is correct
48 Correct 2 ms 3072 KB Output is correct
49 Correct 2 ms 3072 KB Output is correct
50 Correct 26 ms 7808 KB Output is correct
51 Correct 23 ms 7804 KB Output is correct
52 Correct 20 ms 7808 KB Output is correct
53 Correct 18 ms 7752 KB Output is correct
54 Correct 20 ms 7808 KB Output is correct
55 Correct 18 ms 7808 KB Output is correct
56 Correct 22 ms 7808 KB Output is correct
57 Correct 15 ms 6016 KB Output is correct
58 Correct 30 ms 7656 KB Output is correct
59 Correct 12 ms 6016 KB Output is correct
60 Correct 26 ms 7808 KB Output is correct
61 Correct 13 ms 6016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 896 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 896 KB Output is correct
6 Correct 1 ms 896 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 896 KB Output is correct
9 Correct 2 ms 2944 KB Output is correct
10 Correct 2 ms 2944 KB Output is correct
11 Correct 2 ms 2944 KB Output is correct
12 Correct 2 ms 2944 KB Output is correct
13 Correct 2 ms 2944 KB Output is correct
14 Correct 2 ms 2944 KB Output is correct
15 Correct 18 ms 7808 KB Output is correct
16 Correct 17 ms 7808 KB Output is correct
17 Correct 18 ms 7808 KB Output is correct
18 Correct 19 ms 7808 KB Output is correct
19 Correct 19 ms 7808 KB Output is correct
20 Correct 18 ms 7808 KB Output is correct
21 Correct 24 ms 7680 KB Output is correct
22 Correct 21 ms 7808 KB Output is correct
23 Correct 19 ms 7808 KB Output is correct
24 Correct 67 ms 13560 KB Output is correct
25 Correct 65 ms 13560 KB Output is correct
26 Correct 69 ms 13560 KB Output is correct
27 Correct 1 ms 896 KB Output is correct
28 Correct 1 ms 896 KB Output is correct
29 Correct 1 ms 896 KB Output is correct
30 Correct 1 ms 2048 KB Output is correct
31 Correct 2 ms 2304 KB Output is correct
32 Correct 1 ms 1920 KB Output is correct
33 Correct 2 ms 2304 KB Output is correct
34 Correct 2 ms 2688 KB Output is correct
35 Correct 2 ms 2432 KB Output is correct
36 Correct 16 ms 6016 KB Output is correct
37 Correct 16 ms 6272 KB Output is correct
38 Correct 7 ms 3840 KB Output is correct
39 Correct 10 ms 4992 KB Output is correct
40 Correct 11 ms 4864 KB Output is correct
41 Correct 2 ms 2176 KB Output is correct
42 Correct 2 ms 2176 KB Output is correct
43 Correct 10 ms 4608 KB Output is correct
44 Correct 7 ms 3712 KB Output is correct
45 Correct 8 ms 4480 KB Output is correct
46 Correct 4 ms 2944 KB Output is correct
47 Correct 2 ms 2944 KB Output is correct
48 Correct 3 ms 3104 KB Output is correct
49 Correct 2 ms 2944 KB Output is correct
50 Correct 4 ms 3072 KB Output is correct
51 Correct 2 ms 3072 KB Output is correct
52 Correct 2 ms 3072 KB Output is correct
53 Correct 26 ms 7808 KB Output is correct
54 Correct 23 ms 7804 KB Output is correct
55 Correct 20 ms 7808 KB Output is correct
56 Correct 18 ms 7752 KB Output is correct
57 Correct 20 ms 7808 KB Output is correct
58 Correct 18 ms 7808 KB Output is correct
59 Correct 22 ms 7808 KB Output is correct
60 Correct 15 ms 6016 KB Output is correct
61 Correct 30 ms 7656 KB Output is correct
62 Correct 12 ms 6016 KB Output is correct
63 Correct 26 ms 7808 KB Output is correct
64 Correct 13 ms 6016 KB Output is correct
65 Correct 2 ms 2176 KB Output is correct
66 Correct 2 ms 2944 KB Output is correct
67 Correct 3 ms 3200 KB Output is correct
68 Correct 3 ms 3072 KB Output is correct
69 Correct 3 ms 2944 KB Output is correct
70 Correct 18 ms 6912 KB Output is correct
71 Correct 17 ms 6144 KB Output is correct
72 Correct 9 ms 3968 KB Output is correct
73 Correct 4 ms 2816 KB Output is correct
74 Correct 10 ms 3968 KB Output is correct
75 Correct 14 ms 5248 KB Output is correct
76 Correct 43 ms 9728 KB Output is correct
77 Correct 35 ms 9088 KB Output is correct
78 Correct 52 ms 11000 KB Output is correct
79 Correct 3 ms 3328 KB Output is correct
80 Correct 4 ms 3328 KB Output is correct
81 Correct 3 ms 3328 KB Output is correct
82 Correct 4 ms 3328 KB Output is correct
83 Correct 4 ms 3328 KB Output is correct
84 Correct 24 ms 7936 KB Output is correct
85 Correct 25 ms 7988 KB Output is correct
86 Correct 25 ms 7936 KB Output is correct
87 Correct 24 ms 7936 KB Output is correct
88 Correct 24 ms 7936 KB Output is correct
89 Correct 26 ms 7936 KB Output is correct
90 Correct 88 ms 16120 KB Output is correct
91 Correct 85 ms 16120 KB Output is correct
92 Correct 87 ms 16216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 896 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 896 KB Output is correct
6 Correct 1 ms 896 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 896 KB Output is correct
9 Correct 2 ms 2944 KB Output is correct
10 Correct 2 ms 2944 KB Output is correct
11 Correct 2 ms 2944 KB Output is correct
12 Correct 2 ms 2944 KB Output is correct
13 Correct 2 ms 2944 KB Output is correct
14 Correct 2 ms 2944 KB Output is correct
15 Correct 18 ms 7808 KB Output is correct
16 Correct 17 ms 7808 KB Output is correct
17 Correct 18 ms 7808 KB Output is correct
18 Correct 19 ms 7808 KB Output is correct
19 Correct 19 ms 7808 KB Output is correct
20 Correct 18 ms 7808 KB Output is correct
21 Correct 24 ms 7680 KB Output is correct
22 Correct 21 ms 7808 KB Output is correct
23 Correct 19 ms 7808 KB Output is correct
24 Correct 67 ms 13560 KB Output is correct
25 Correct 65 ms 13560 KB Output is correct
26 Correct 69 ms 13560 KB Output is correct
27 Correct 42 ms 81528 KB Output is correct
28 Correct 41 ms 81496 KB Output is correct
29 Correct 42 ms 81784 KB Output is correct
30 Correct 44 ms 81636 KB Output is correct
31 Correct 41 ms 81788 KB Output is correct
32 Correct 43 ms 81788 KB Output is correct
33 Execution timed out 1580 ms 275904 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 896 KB Output is correct
2 Correct 1 ms 896 KB Output is correct
3 Correct 1 ms 896 KB Output is correct
4 Correct 1 ms 896 KB Output is correct
5 Correct 1 ms 896 KB Output is correct
6 Correct 1 ms 896 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 896 KB Output is correct
9 Correct 2 ms 2944 KB Output is correct
10 Correct 2 ms 2944 KB Output is correct
11 Correct 2 ms 2944 KB Output is correct
12 Correct 2 ms 2944 KB Output is correct
13 Correct 2 ms 2944 KB Output is correct
14 Correct 2 ms 2944 KB Output is correct
15 Correct 18 ms 7808 KB Output is correct
16 Correct 17 ms 7808 KB Output is correct
17 Correct 18 ms 7808 KB Output is correct
18 Correct 19 ms 7808 KB Output is correct
19 Correct 19 ms 7808 KB Output is correct
20 Correct 18 ms 7808 KB Output is correct
21 Correct 24 ms 7680 KB Output is correct
22 Correct 21 ms 7808 KB Output is correct
23 Correct 19 ms 7808 KB Output is correct
24 Correct 67 ms 13560 KB Output is correct
25 Correct 65 ms 13560 KB Output is correct
26 Correct 69 ms 13560 KB Output is correct
27 Correct 42 ms 81528 KB Output is correct
28 Correct 41 ms 81496 KB Output is correct
29 Correct 42 ms 81784 KB Output is correct
30 Correct 44 ms 81636 KB Output is correct
31 Correct 41 ms 81788 KB Output is correct
32 Correct 43 ms 81788 KB Output is correct
33 Execution timed out 1580 ms 275904 KB Time limit exceeded
34 Halted 0 ms 0 KB -