답안 #289362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289362 2020-09-02T15:30:25 Z beso123 벽 칠하기 (APIO20_paint) C++14
0 / 100
1500 ms 384 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
int minimumInstructions(int n,int m,int s,vector<int> col,vector<int> Size,vector<vector<int>> b){
    vector<int> mp[s+1];
    for(int k=0;k<m;k++){
        for(int i=0;i<Size[k];i++){
            mp[b[k][i]].push_back(k);
        }
    }
    deque<int> v;
    v.resize(m,0);
    for(int k=0;k<m;k++){
        for(int i=0;i<mp[col[k]].size();i++){
            int nom=mp[col[k]][i];
            nom=((nom-k)+m)%m;
            v[nom]++;
        }
    }
    vector<int> a(n,0);
    for(int k=0;k<v.size();k++)
        if(v[k]==m)
            a[m-1]++;
    for(int k=m;k<n;k++){
        int cl=col[k-m];
        for(int i=0;i<mp[cl].size();i++){
            v[mp[cl][i]]--;
        }
        cl=col[k];
        int x=v[v.size()-1];
        v.pop_back();
        v.push_front(x);
        for(int i=0;i<mp[cl].size();i++){
            v[(mp[cl][i]+1)%m]++;
           if(v[(mp[cl][i]+1)%m]==m)
            a[k]++;
        }
    }
    int ans=0;
    vector<int> w(n+1,-1);
    if(a[m-1]==1)
        w[m-1]=m-1;
    for(int k=m;k<n;k++){
        w[k]=w[k-1];
        if(a[k]==1)
            w[k]=k;
    }
    int j=m-1;
    while(true){
        if(w[j]==-1)
            return -1;
            ans++;
            if(j==n-1)
                break;
        int i=(j+m)%n;
        if(w[i]==w[j])
            return -1;
        j=w[i];
    }
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int i=0;i<mp[col[k]].size();i++){
      |                     ~^~~~~~~~~~~~~~~~~~
paint.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int k=0;k<v.size();k++)
      |                 ~^~~~~~~~~
paint.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i=0;i<mp[cl].size();i++){
      |                     ~^~~~~~~~~~~~~~
paint.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=0;i<mp[cl].size();i++){
      |                     ~^~~~~~~~~~~~~~
paint.cpp:50:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   50 |         if(w[j]==-1)
      |         ^~
paint.cpp:52:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   52 |             ans++;
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Execution timed out 1586 ms 256 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Execution timed out 1586 ms 256 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Execution timed out 1586 ms 256 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Execution timed out 1586 ms 256 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Execution timed out 1586 ms 256 KB Time limit exceeded
9 Halted 0 ms 0 KB -