제출 #550509

#제출 시각아이디문제언어결과실행 시간메모리
550509Jarif_Rahman벽 칠하기 (APIO20_paint)C++17
28 / 100
1584 ms10708 KiB
#include "paint.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int minimumInstructions(int n, int m, int K, vector<int> C, vector<int> A, vector<vector<int>> B){ vector<unordered_set<int>> likes(m); for(int i = 0; i < m; i++) for(int x: B[i]) likes[i].insert(x); vector<vector<int>> has_color(K); vector<unordered_map<int, int>> sth(n); for(int i = 0; i < n; i++) has_color[C[i]].pb(i); for(int i = 0; i < m; i++) for(int x: B[i]) for(int y: has_color[x]) sth[y][i] = 1; vector<bool> p(n, 0); for(int i = n-m; i >= 0; i--){ for(int j = 0; j < m; j++){ bool ok = 1; for(int k = 0; k < m; k++) if(likes[(j+k)%m].find(C[i+k]) == likes[(j+k)%m].end()) ok = 0; p[i] = p[i]|ok; } } int ans = 0, ls = -1, c = 0; for(int i = n-1; i >= 0; i--){ c++; if(p[i]) ls = i; if(c == m || i == 0){ if(ls == -1) return -1; ans++; c=ls-i; ls = -1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...