Submission #784387

# Submission time Handle Problem Language Result Execution time Memory
784387 2023-07-16T05:08:15 Z Hanksburger Painting Walls (APIO20_paint) C++17
0 / 100
2 ms 3796 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005], w[50005];
int ok[100005];
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++)
        for (int j=0; j<a[i]; j++)
            v[b[i][j]].push_back(i);
    for (int i=0; i<n; i++)
        for (int j=0; j<v[c[i]].size(); j++)
            w[(v[c[i]][j]-i+n)%m].push_back(i);
    for (int i=0; i<m; i++)
    {
        int cnt;
        for (int j=0; j<w[i].size(); j++)
        {
            if (j && w[i][j]-w[i][j-1]==1)
                cnt++;
            else
                cnt=1;
            if (cnt>=m)
                ok[w[i][j]]=1;
        }
    }
    if (!ok[m-1])
        return 0;
    int ind=m-1, ans=1;
    while (ind<n-1)
    {
        int pre=ind;
        for (int i=min(n-1, ind+m); i>ind; i--)
        {
            if (ok[i])
            {
                ind=i;
                break;
            }
        }
        if (ind==pre)
            return 0;
        ans++;
    }
    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:12:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for (int j=0; j<v[c[i]].size(); j++)
      |                       ~^~~~~~~~~~~~~~~
paint.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int j=0; j<w[i].size(); j++)
      |                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Incorrect 2 ms 3796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Incorrect 2 ms 3796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Incorrect 2 ms 3796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Incorrect 2 ms 3796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Incorrect 2 ms 3796 KB Output isn't correct
4 Halted 0 ms 0 KB -