답안 #949383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949383 2024-03-19T07:39:41 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
0 / 100
0 ms 512 KB
#include <bits/stdc++.h>
#include "paint.h"
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int minimumInstructions(int N, int M, int K,vector<int> C,vector<int> A, vector<vector<int>> B) {
    for(int i=0;i<M;i++){
        sort(all(B[i]));
    }
    int ans=0;
    vector <int> used(N);
    for(int i=0;i<N;i++){
        if(!used[i] && i+M-1<N){
            
            for(int y=i;y>=max(0,i-M+1);y--){
                bool ok=0;
                for(int x=0;x<M;x++){
                    int cnt=0;
                    for(int l=0;l<M;l++){
                        int pos=(x+l)%M;
                        auto it=lower_bound(all(B[pos]),C[y+l]);
                        if(it!=B[pos].end() && *it==C[y+l])cnt++;
                        else break;
                    }
                    if(cnt==M)ok=1;
                }
                if(ok){
                   
                    for(int j=y;j<y+M;j++)used[j]=1;
                    ans++;
                    break;
                }
            }
        }
        
    }
    if(ans==0)ans=-1;
    return ans;
}

/*signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    vector <int> c(n),a(m);
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<m;i++)cin>>a[i];
    vector <vector <int> > b(m);
    for(int i=0;i<m;i++){
        for(int j=0;j<a[i];j++){
            int x;
            cin>>x;
            b[i].pb(x);
        }
    }
    cout<<minimumInstructions(n,m,k,c,a,b)<<"\n";
}*/
/*
 8 3 5
 3 3 1 3 4 4 2 2
 3 2 2
 0 1 2
 2 3
 3 4
 
 
 5 4 4
 1 0 1 2 2
 2 1 1 1
 0 1
 1
 2
 3
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 512 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 512 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 512 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 512 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 512 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -