Submission #384734

#TimeUsernameProblemLanguageResultExecution timeMemory
384734kwongwengPainting Walls (APIO20_paint)C++17
Compilation error
0 ms0 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) int minimumInstructions(int n, int m, int k, vi c, vi a, vector<vi> b) { int ans = 1; vi num(m); vector<vi> con; FOR(i, 0, k){ vi q; con.pb(q); } FOR(i, 0, m){ FOR(j, 0, a[i]){ con[b[i][j]].push_back(i); } } FOR(i, 0, m){ FOR(j, 0, con[c[i]].size()){ int k = con[c[i]][j]; k = (k + m - i) % m; num[k]++; } } int cnt = 0; FOR(i, 0, m){ if (num[i] == m) cnt++; } vi check(n); if (cnt > 0) check[0] = 1; FOR(i, 0, n-m){ FOR(j, 0, con[c[i]].size()){ int k = con[c[i]][j]; k = (k + m - i) % m; if (num[k] == m) cnt--; num[k]--; } FOR(j, 0, con[c[i+m]].size()){ int k = con[c[i+m]][j]; k = (k + m - i) % m; if (num[k] == m-1) cnt++; num[k]++; } if (cnt > 0) check[i+1] = 1; } bool sol = true; int cur = 0; while (cur < n-m){ if (check[cur] != 1){ ans = -1; break; } ans++; int r = -1; ROF(i, cur + m, cur+1){ if (check[i] == 1){ r = i; break; } } if (r == -1){ ans = - 1; break; } cur = r; } if (check[n-m] != 1) ans = -1; else return ans; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, vi, vi, std::vector<std::vector<int> >)':
paint.cpp:15:13: error: 'class std::vector<std::vector<int> >' has no member named 'pb'
   15 |         con.pb(q);
      |             ^~
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   23 |         FOR(j, 0, con[c[i]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~     
paint.cpp:23:9: note: in expansion of macro 'FOR'
   23 |         FOR(j, 0, con[c[i]].size()){
      |         ^~~
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   36 |         FOR(j, 0, con[c[i]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~     
paint.cpp:36:9: note: in expansion of macro 'FOR'
   36 |         FOR(j, 0, con[c[i]].size()){
      |         ^~~
paint.cpp:6:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   42 |         FOR(j, 0, con[c[i+m]].size()){
      |             ~~~~~~~~~~~~~~~~~~~~~~~~   
paint.cpp:42:9: note: in expansion of macro 'FOR'
   42 |         FOR(j, 0, con[c[i+m]].size()){
      |         ^~~
paint.cpp:50:10: warning: unused variable 'sol' [-Wunused-variable]
   50 |     bool sol = true;
      |          ^~~
paint.cpp:11:13: warning: control reaches end of non-void function [-Wreturn-type]
   11 |     vi num(m);
      |             ^