Submission #1056291

# Submission time Handle Problem Language Result Execution time Memory
1056291 2024-08-13T08:41:44 Z dosts Painting Walls (APIO20_paint) C++17
0 / 100
0 ms 348 KB
#include "paint.h"
//Dost Seferoğlu
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
using namespace std;
//#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e9;
const int N = 2e5;

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
      vector<int> f[K];
      for (int i=0;i<M;i++) {
        for (int j=0;j<A[i];j++) {
          f[B[i][j]].push_back(i);
        }
      }
      vector<bool> cool(N,0);
      for (int i=0;i<=N-M;i++) {
        for (int j=0;j<M;j++) {
          bool fll = 1;
          for (int jj=0;jj<M;jj++) {
            auto iter = lower_bound(all(f[C[i+jj]]),(j+jj)%M);
            if (iter == f[C[i+jj]].end() || ((*iter) != (j+jj)%M)) fll = 0;
          }
          if (fll) cool[i] = 1;
        }
      }

      int ans = 0;
      int cover = 0;
      stack<int> cools;
      for (int i=0;i<N;i++) {
        if (cool[i]) cools.push(i);
        if (cover < i) {
          if (cools.empty() || cools.top()+M-1 < i) {
            ans = inf;
            break;
          }
          else {
            ans++;
            cover = cools.top()+M-1;
            cools.pop();
          }
        }
      }
      return ((ans >= inf)?-1:ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -