답안 #741430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741430 2023-05-14T05:09:36 Z penguin133 벽 칠하기 (APIO20_paint) C++17
0 / 100
6 ms 9696 KB
#include <bits/stdc++.h>
using namespace std;

#include "paint.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool ok[200005];
vector <int> brr[200005], grr[200005];
int dp[200005];
int stuf[200005];
int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
  for(int i=0;i<M;i++){
	  for(auto j : B[i])brr[j].push_back(i);
  }
  for(int i=0;i<M;i++)stuf[i] = M;
  for(int i=0;i<M-1;i++){
	for(auto j : brr[C[i]])stuf[(j - i + 1000 * M) % M]--;  
  }
  for(int i=M-1;i<N;i++){
	  for(auto j : brr[C[i]])stuf[(j - i + 1000 * M) % M]--;
	  int rv = i - (M - 1) - 1;
	  if(rv >= 0){
		  for(auto j : brr[C[rv]])stuf[(j - rv + 1000 * M) % M]++;
	  }
	  for(int j=0;j<M;j++)if(stuf[j] == 0)ok[i] = 1;
  }
  for(int i = 0; i < M - 1; i++)dp[i] = 2e9;
  for(int i=M - 1;i<N;i++){
	  dp[i] = 2e9;
	  //cout << ok[i] << ' ';
	  if(ok[i]){
		  int tmp= 2e9;
		  if(i == M - 1)tmp = 0;
		  for(int j = i - 1; j >= max(0, i - M); j--)tmp = min(tmp, dp[j]);
		  dp[i] = tmp + 1;
	  }
  }
  return (dp[N - 1] == 2e9 ? -1 : dp[N - 1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9696 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9596 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9640 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 6 ms 9696 KB Output is correct
9 Incorrect 6 ms 9684 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9696 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9596 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9640 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 6 ms 9696 KB Output is correct
9 Incorrect 6 ms 9684 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9696 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9596 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9640 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 6 ms 9696 KB Output is correct
9 Incorrect 6 ms 9684 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9696 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9596 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9640 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 6 ms 9696 KB Output is correct
9 Incorrect 6 ms 9684 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9696 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9596 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9640 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 6 ms 9696 KB Output is correct
9 Incorrect 6 ms 9684 KB Output isn't correct
10 Halted 0 ms 0 KB -