답안 #436192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436192 2021-06-24T10:15:20 Z aymane7 벽 칠하기 (APIO20_paint) C++17
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
#include "paint.h"
#pragma GCC optimize("O2")
#define deb(x) cout << #x << " = " << x <<endl
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int minimumInstructions(int n,int m,int k,vector<int> c,vector<int> a,vector<vector<int>> b){
    vector<int> mp(k,-1);
    //mp[i] = position of constructor who like the i th color
    for(int i=0;i<m;i++)
        if(a[i]>0)
            mp[b[i][0]]=i;
    int ans=0,cur=-1;
    //cur moves in constructors array
    for(int i=0;i<n;i++){
        if(mp[c[i]]==-1)
            return -1;
        if(cur==-1)
            ans++,cur=mp[c[i]];
        else{
            cur=(cur+1)%m;
            if(a[cur]>0 && b[cur][0]==c[i])
                continue;
            ans++;
            cur=mp[c[i]];
        }
    }
    return ans;
}
/*
int main(){
    createFunTour(2,0);
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -