답안 #961969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961969 2024-04-12T23:45:21 Z Mohamed_Kachef06 벽 칠하기 (APIO20_paint) C++17
컴파일 오류
0 ms 0 KB
#include "paint.h"
#include "grader.cpp"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

bool poss[400'001];
int dp[100'001]; 
int n , m ,  k ;

int brute(int i){
   if (i == n-1) return 0; 
   else if (i >= n) return 1e9;
   if (~dp[i]) return dp[i]; 
   int ans = 1e9; 
   if (poss[i]){
     for (int j = i+1 ; j <= i+m ; j++) ans = min(ans , brute(j) + 1);  
   }
   return dp[i] = ans; 
}

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
      n = N; m = M; k = K; 
      // N number of segments 
      // M number of contractors
      // C(n) the intended color for each segment
      // A(m) the number of colors each contractor likes 
      // B(m) the set of colors each contractor likes 
      for (auto &i : B ) sort(i.begin() , i.end());
     for (int y = 0; y <= N-M ; y++){
         for (int x = 0 ; x < M ; x++){
          bool f = 1;
          for (int l = 0 ; l < M ; l++){
            int cont = (x+l)%M ; 
            if (!binary_search(B[cont].begin() , B[cont].end() , C[y+l])) {f = 0; break;} 
          }
          if (f) {poss[y] = 1; break; } 
        }
      }
      memset(dp , -1 , sizeof dp); 
      int ans = brute(0);
  return (ans == 1e9 ? -1 : ans); 
}

Compilation message

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