Submission #949323

# Submission time Handle Problem Language Result Execution time Memory
949323 2024-03-19T06:13:38 Z vjudge1 Painting Walls (APIO20_paint) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

//#include "paint.h"


using namespace std;

const int inf = 1e9;

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	vector <int> dp(N + 1, inf);
	set <int> st[M];
	for(int i = 0; i < M; i++){
		for(auto x : B[i]){
			st[i].insert(x);
		}
	}
	for(int i = 0; i + M - 1 < N; i++){
		for(int j = 0; j < M; j++){
			bool flag = 1;
			for(int l = 0; l < M; l++){
				if(st[(l + j) % M].find(C[i + l]) == st[(l + j) % M].end()){
					flag = 0;
					break;
				}
			}
			if(flag){
				if(i == 0)
					dp[i + M - 1] = 1;
				else{
					for(int j = i - 1; j < i + M - 1; j++){
						dp[i + M - 1] = min(dp[j] + 1,dp[i + M - 1]);
						//cout << dp[j] <<"=" << j << endl;
					}
				}
				//cout << i <<"-"<< dp[i + M - 1] << endl;
				//break;
			}
		}
	}
	if(dp[N - 1] == inf)
		return -1;
	return dp[N - 1];
}



int main() {
  int N, M, K;
  assert(3 == scanf("%d %d %d", &N, &M, &K));
  
  std::vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    assert(1 == scanf("%d", &C[i]));
  }

  std::vector<int> A(M);
  std::vector<std::vector<int>> B(M);
  for (int i = 0; i < M; ++i) {
    assert(1 == scanf("%d", &A[i]));
    B[i].resize(A[i]);
    for (int j = 0; j < A[i]; ++j) {
      assert(1 == scanf("%d", &B[i][j]));
    }
  }

  int minimum_instructions = minimumInstructions(N, M, K, C, A, B);
  printf("%d\n", minimum_instructions);
  
  return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccG1UCtq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccx0QRdn.o:paint.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status