Submission #384748

# Submission time Handle Problem Language Result Execution time Memory
384748 2021-04-02T07:11:34 Z kwongweng Painting Walls (APIO20_paint) C++14
0 / 100
3 ms 3308 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)

vi num(50000);
vector<vi> con(100000);
vi check(100000);

int minimumInstructions(int n, int m, int k, vi c, vi a, vector<vi> b) {
    int ans = 1;
    num.resize(m); check.resize(n); con.resize(k);
    FOR(i, 0, m){
        FOR(j, 0, a[i]){
            con[b[i][j]].push_back(i);
        }
    }
    FOR(i, 0, m){
        FOR(j, 0, con[c[i]].size()){
            int k = con[c[i]][j];
            num[(k-i+m)%m]++;
        }
    }
    int cnt = 0;
    FOR(i, 0, m){
        if (num[i] == m) cnt++;
    }
    if (cnt > 0) check[0] = 1;
    FOR(i, 0, n-m){
        FOR(j, 0, con[c[i]].size()){
            int k = con[c[i]][j];
            k = (k - i + m) % m;
            if (num[k] == m) cnt--;
            num[k]--;
        }
        FOR(j, 0, con[c[i+m]].size()){
            int k = con[c[i+m]][j];
            k = (k - i + m) % m;
            if (num[k] == m-1) cnt++;
            num[k]++;
        }
        if (cnt > 0) check[i+1] = 1;
    }
    int r = 0;
    FOR(i, 0, n-m+1){
        if (i < r) continue;
        if (i > r){
            ans = -1;
            break;
        }
        ans++;
        FOR(j, i+1, i+m+1){
            if (check[j] == 1) r = j;
        }
    }
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, vi, vi, std::vector<std::vector<int> >)':
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   22 |         FOR(j, 0, con[c[i]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~     
paint.cpp:22:9: note: in expansion of macro 'FOR'
   22 |         FOR(j, 0, con[c[i]].size()){
      |         ^~~
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   33 |         FOR(j, 0, con[c[i]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~     
paint.cpp:33:9: note: in expansion of macro 'FOR'
   33 |         FOR(j, 0, con[c[i]].size()){
      |         ^~~
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   39 |         FOR(j, 0, con[c[i+m]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~~~   
paint.cpp:39:9: note: in expansion of macro 'FOR'
   39 |         FOR(j, 0, con[c[i+m]].size()){
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -