QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#405065#435. Painting WallsMax_s_xaM100 ✓13ms10140kbC++201.1kb2024-05-05 10:12:002024-05-05 10:12:01

Judging History

This is the latest submission verdict.

  • [2024-05-05 10:12:01]
  • Judged
  • Verdict: 100
  • Time: 13ms
  • Memory: 10140kb
  • [2024-05-05 10:12:00]
  • Submitted

answer

#include "paint.h"
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;
typedef double lf;

using namespace std;

const int MAXN = 1e5 + 10;

int n, m, k;
vector <int> col[MAXN], pos[MAXN];
bool avl[MAXN];

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 = 0; i < m; i++)
    {
        for (int j = 0; j < A[i]; j++)
            col[B[i][j]].push_back(i);
    }
    for (int i = 0; i < n; i++)
    {
        int c = C[i];
        for (auto x : col[c])
            pos[(x - i + m) % m].push_back(i);
    }
    for (int i = 0; i < m; i++)
    {
        int len = 0, lst = 0;
        for (auto x : pos[i])
        {
            if (x == lst + 1) len++;
            else len = 1;
            if (len >= m) avl[x - m + 1] = 1;
            lst = x;
        }
    }
    int p = 0, mx = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (i > p) {ans = -1; break;}
        if (avl[i]) mx = i + m;
        if (i == p) p = mx, ans++;
    }
    return ans;
}

詳細信息

Subtask #1:

score: 0
Accepted

Test #1:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

1 1 1
0
1 0

output:

1

result:

ok single line: '1'

Subtask #2:

score: 0
Accepted

Test #22:

score: 0
Accepted
time: 13ms
memory: 10140kb

input:

500 200 100000
43773 40354 2348 52596 62314 89070 43591 1761 54688 6485 17304 56821 36 36327 32247 51209 74080 85034 19128 45821 41096 74616 95383 41097 42368 1703 71263 45273 86316 3332 86662 41554 26490 26341 48653 30964 66532 75488 33898 97982 27906 26546 14311 22085 6620 80880 55703 13418 59470 ...

output:

-1

result:

ok single line: '-1'

Subtask #3:

score: 0
Accepted

Test #25:

score: 0
Accepted
time: 0ms
memory: 4052kb

input:

20000 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

20000

result:

ok single line: '20000'

Subtask #4:

score: 0
Accepted

Test #40:

score: 0
Accepted
time: 6ms
memory: 5060kb

input:

90737 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

90737

result:

ok single line: '90737'

Subtask #5:

score: 0
Accepted

Test #67:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

2 2 1
0 0
1 0
1 0

output:

1

result:

ok single line: '1'

Subtask #6:

score: 0
Accepted

Test #105:

score: 0
Accepted
time: 1ms
memory: 4260kb

input:

253 186 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

2

result:

ok single line: '2'

Subtask #7:

score: 0
Accepted

Test #133:

score: 0
Accepted
time: 2ms
memory: 4456kb

input:

19884 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

9942

result:

ok single line: '9942'

Subtask #8:

score: 0
Accepted

Test #177:

score: 0
Accepted
time: 0ms
memory: 4456kb

input:

61996 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

30998

result:

ok single line: '30998'

Subtask #9:

score: 12
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Subtask #10:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #5:

100%
Accepted

Subtask #11:

score: 13
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Subtask #12:

score: 23
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Subtask #13:

score: 37
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Dependency #10:

100%
Accepted

Dependency #11:

100%
Accepted

Dependency #12:

100%
Accepted

Extra Test:

score: 0
Extra Test Passed