답안 #289376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289376 2020-09-02T15:42:46 Z beso123 벽 칠하기 (APIO20_paint) C++14
12 / 100
95 ms 13492 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
int minimumInstructions(int n,int m,int s,vector<int> col,vector<int> Size,vector<vector<int>> b){
    vector<int> mp[s+1];
    for(int k=0;k<m;k++){
        for(int i=0;i<Size[k];i++){
            mp[b[k][i]].push_back(k);
        }
    }
    deque<int> v;
    v.resize(m,0);
    for(int k=0;k<m;k++){
        for(int i=0;i<mp[col[k]].size();i++){
            int nom=mp[col[k]][i];
            nom=((nom-k)+m)%m;
            v[nom]++;
        }
    }
    vector<int> a(n,0);
    for(int k=0;k<v.size();k++)
        if(v[k]==m)
            a[m-1]++;
    for(int k=m;k<n;k++){
        int cl=col[k-m];
        for(int i=0;i<mp[cl].size();i++){
            v[mp[cl][i]]--;
        }
        cl=col[k];
        int x=v[v.size()-1];
        v.pop_back();
        v.push_front(x);
        for(int i=0;i<mp[cl].size();i++){
            v[(mp[cl][i]+1)%m]++;
           if(v[(mp[cl][i]+1)%m]==m)
            a[k]++;
        }
    }
    int ans=0;
    vector<int> w(n+1,-1);
    if(a[m-1]==1)
        w[m-1]=m-1;
    for(int k=m;k<n;k++){
        w[k]=w[k-1];
        if(a[k]==1)
            w[k]=k;
    }
    int j=m-1;
    while(true){
        if(w[j]==-1)
            return -1;
            ans++;
            if(j==n-1)
                break;
        int i=(j+m);
        if(i>=n)
            i=n-1;
        if(w[i]==w[j])
            return -1;
        j=w[i];
    }
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int i=0;i<mp[col[k]].size();i++){
      |                     ~^~~~~~~~~~~~~~~~~~
paint.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int k=0;k<v.size();k++)
      |                 ~^~~~~~~~~
paint.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i=0;i<mp[cl].size();i++){
      |                     ~^~~~~~~~~~~~~~
paint.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=0;i<mp[cl].size();i++){
      |                     ~^~~~~~~~~~~~~~
paint.cpp:50:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   50 |         if(w[j]==-1)
      |         ^~
paint.cpp:52:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   52 |             ans++;
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 416 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 3 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 3 ms 2688 KB Output is correct
20 Correct 7 ms 2720 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 30 ms 6520 KB Output is correct
23 Correct 29 ms 6528 KB Output is correct
24 Correct 34 ms 6652 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 640 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 4 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 15 ms 3840 KB Output is correct
32 Correct 13 ms 3840 KB Output is correct
33 Correct 13 ms 3840 KB Output is correct
34 Correct 19 ms 3840 KB Output is correct
35 Correct 13 ms 3840 KB Output is correct
36 Correct 21 ms 3840 KB Output is correct
37 Correct 40 ms 7040 KB Output is correct
38 Correct 52 ms 7032 KB Output is correct
39 Correct 40 ms 7032 KB Output is correct
40 Correct 14 ms 1792 KB Output is correct
41 Correct 9 ms 1152 KB Output is correct
42 Correct 16 ms 1920 KB Output is correct
43 Correct 10 ms 1280 KB Output is correct
44 Correct 9 ms 1280 KB Output is correct
45 Correct 16 ms 1920 KB Output is correct
46 Correct 65 ms 12664 KB Output is correct
47 Correct 44 ms 7928 KB Output is correct
48 Correct 46 ms 10488 KB Output is correct
49 Correct 62 ms 10616 KB Output is correct
50 Correct 67 ms 10360 KB Output is correct
51 Correct 48 ms 7800 KB Output is correct
52 Correct 16 ms 1920 KB Output is correct
53 Correct 15 ms 1920 KB Output is correct
54 Correct 18 ms 1920 KB Output is correct
55 Correct 16 ms 1920 KB Output is correct
56 Correct 16 ms 1920 KB Output is correct
57 Correct 16 ms 1920 KB Output is correct
58 Correct 76 ms 13432 KB Output is correct
59 Correct 69 ms 13436 KB Output is correct
60 Correct 69 ms 13432 KB Output is correct
61 Correct 69 ms 13492 KB Output is correct
62 Correct 76 ms 13492 KB Output is correct
63 Correct 74 ms 13432 KB Output is correct
64 Correct 81 ms 12664 KB Output is correct
65 Correct 95 ms 12792 KB Output is correct
66 Correct 86 ms 12664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 7 ms 2720 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Incorrect 0 ms 256 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 7 ms 2720 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 30 ms 6520 KB Output is correct
25 Correct 29 ms 6528 KB Output is correct
26 Correct 34 ms 6652 KB Output is correct
27 Incorrect 0 ms 256 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 7 ms 2720 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 30 ms 6520 KB Output is correct
25 Correct 29 ms 6528 KB Output is correct
26 Correct 34 ms 6652 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 4 ms 640 KB Output is correct
29 Correct 4 ms 640 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 15 ms 3840 KB Output is correct
34 Correct 13 ms 3840 KB Output is correct
35 Correct 13 ms 3840 KB Output is correct
36 Correct 19 ms 3840 KB Output is correct
37 Correct 13 ms 3840 KB Output is correct
38 Correct 21 ms 3840 KB Output is correct
39 Correct 40 ms 7040 KB Output is correct
40 Correct 52 ms 7032 KB Output is correct
41 Correct 40 ms 7032 KB Output is correct
42 Incorrect 0 ms 256 KB Output isn't correct
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 7 ms 2720 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 30 ms 6520 KB Output is correct
25 Correct 29 ms 6528 KB Output is correct
26 Correct 34 ms 6652 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 4 ms 640 KB Output is correct
29 Correct 4 ms 640 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 15 ms 3840 KB Output is correct
34 Correct 13 ms 3840 KB Output is correct
35 Correct 13 ms 3840 KB Output is correct
36 Correct 19 ms 3840 KB Output is correct
37 Correct 13 ms 3840 KB Output is correct
38 Correct 21 ms 3840 KB Output is correct
39 Correct 40 ms 7040 KB Output is correct
40 Correct 52 ms 7032 KB Output is correct
41 Correct 40 ms 7032 KB Output is correct
42 Correct 14 ms 1792 KB Output is correct
43 Correct 9 ms 1152 KB Output is correct
44 Correct 16 ms 1920 KB Output is correct
45 Correct 10 ms 1280 KB Output is correct
46 Correct 9 ms 1280 KB Output is correct
47 Correct 16 ms 1920 KB Output is correct
48 Correct 65 ms 12664 KB Output is correct
49 Correct 44 ms 7928 KB Output is correct
50 Correct 46 ms 10488 KB Output is correct
51 Correct 62 ms 10616 KB Output is correct
52 Correct 67 ms 10360 KB Output is correct
53 Correct 48 ms 7800 KB Output is correct
54 Correct 16 ms 1920 KB Output is correct
55 Correct 15 ms 1920 KB Output is correct
56 Correct 18 ms 1920 KB Output is correct
57 Correct 16 ms 1920 KB Output is correct
58 Correct 16 ms 1920 KB Output is correct
59 Correct 16 ms 1920 KB Output is correct
60 Correct 76 ms 13432 KB Output is correct
61 Correct 69 ms 13436 KB Output is correct
62 Correct 69 ms 13432 KB Output is correct
63 Correct 69 ms 13492 KB Output is correct
64 Correct 76 ms 13492 KB Output is correct
65 Correct 74 ms 13432 KB Output is correct
66 Correct 81 ms 12664 KB Output is correct
67 Correct 95 ms 12792 KB Output is correct
68 Correct 86 ms 12664 KB Output is correct
69 Incorrect 0 ms 256 KB Output isn't correct
70 Halted 0 ms 0 KB -