Submission #974919

# Submission time Handle Problem Language Result Execution time Memory
974919 2024-05-04T07:02:41 Z hirayuu_oj Painting Walls (APIO20_paint) C++17
0 / 100
1 ms 348 KB
#include "paint.h"
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) x.begin(),x.end();
using ll=long long;

int minimumInstructions(
        int N, int M, int K, std::vector<int> C,
        std::vector<int> A, std::vector<std::vector<int>> B) {
    vector<vector<int>> cols(K);
    rep(i,M){
        for(int j:B[i]){
            cols[j].emplace_back(i);
        }
    }
    int ans=0;
    int cnt=0;
    vector<int> can;
    rep(i,N){
        if(!can.empty()){
            vector<int> nxt;
            for(int j:can){
                int now=(j+1)%M;
                if(*lower_bound(B[now].begin(),B[now].end(),C[i])==C[i]){
                    nxt.emplace_back(now);
                }
            }
            swap(can,nxt);
            if(can.empty()){
                if(ans==0){
                    return -1;
                }
                cnt=0;
                ans++;
                can.clear();
            }
        }
        if(cnt==0){
            can=cols[C[i]];
            if(can.empty()){
                return -1;
            }
        }
        cnt++;
        if(cnt==M){
            cnt=0;
            ans++;
            can.clear();
        }
    }
    if(cnt!=0)ans++;
    return ans;
}
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -