Submission #981001

# Submission time Handle Problem Language Result Execution time Memory
981001 2024-05-12T17:17:36 Z Abito Painting Walls (APIO20_paint) C++17
0 / 100
1 ms 2632 KB
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define ep insert
using namespace std;
const int NN=2e4+5,MM=2e3+5;
int n,m,k,p[NN][MM],c[NN],dp[NN];
vector<int> v[MM];
set<int> adj[MM];
int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B){
    n=N;m=M;k=K;
    for (int i=1;i<=n;i++) c[i]=C[i-1]+1;
    for (int i=1;i<=m;i++){
        for (auto u:B[i-1]) adj[i].ep(u+1),v[i].pb(u+1);
    }
    for (int i=1;i<n;i++){
        for (int j=1;j<=m;j++){
            if (j==m) p[i][j]=(adj[j].count(c[i]) && adj[1].count(c[i+1]));
            else p[i][j]=(adj[j].count(c[i]) && adj[j+1].count(c[i+1]));
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            p[i][j]+=p[i-1][j-1];
        }
    }
    /*-for (int i=1;i<n;i++){
        for (int j=1;j<=m;j++){
            cout<<p[i][j];
        }cout<<endl;
    }*/
    multiset<int> s;
    for (int i=1;i<=n-m+1;i++) dp[i]=10*n;
    for (int i=1;i<=m;i++) s.ep(0);
    for (int i=n-m+1;i;i--){
        bool ok=false;
        ok|=(p[i+m-2][m-1]==m-1);
        for (int j=2;j<=m;j++){
            int r=m+1-j;
            ok|=(p[i+r-1][j+r-1]-p[i-1][j-1]+p[i+m-2][m-r-1]==m-1);
            //cout<<p[i+r-1][j+r-1]-p[i-1][j-1]+p[i+m-2][m-r-1]<<endl;
        }
        if (ok) dp[i]=*s.begin()+1;
        s.ep(dp[i]);
        if (s.size()>m) s.erase(s.find(dp[i+m]));
    }
    //for (int i=1;i<=n;i++) cout<<dp[i]<<' ';cout<<endl;
    if (dp[1]>=10*n) dp[1]=-1;
    return dp[1];
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:47:21: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if (s.size()>m) s.erase(s.find(dp[i+m]));
      |             ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2632 KB Output isn't correct
4 Halted 0 ms 0 KB -