Submission #781071

#TimeUsernameProblemLanguageResultExecution timeMemory
781071BlagojPaint By Numbers (IOI16_paint)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; int n, m; int h[MAXN], v[MAXN]; int a[MAXN][MAXN]; int dp[MAXN][MAXN]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> h[i]; } for (int j = 1; j <= m; j++) { cin >> v[j]; } // Initialize the first row and column of the dp table dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][0] = dp[i-1][0] && (h[i] == 0); } for (int j = 1; j <= m; j++) { dp[0][j] = dp[0][j-1] && (v[j] == 0); } // Fill in the rest of the dp table for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (h[i] == 0 && v[j] == 0) { dp[i][j] = dp[i-1][j] || dp[i][j-1]; } else if (h[i] == 0) { int sum = 0; for (int k = j-v[j]; k <= j-1; k++) { sum += a[i][k]; } dp[i][j] = (sum == 0) && dp[i-1][j]; } else if (v[j] == 0) { int sum = 0; for (int k = i-h[i]; k <= i-1; k++) { sum += a[k][j]; } dp[i][j] = (sum == 0) && dp[i][j-1]; } else { int sum1 = 0; for (int k = i-h[i]; k <= i-1; k++) { sum1 += a[k][j]; } int sum2 = 0; for (int k = j-v[j]; k <= j-1; k++) { sum2 += a[i][k]; } dp[i][j] = (sum1 == 0) && (sum2 == 0) && dp[i-1][j] && dp[i][j-1]; } if (dp[i][j]) { if (h[i] > 0) { for (int k = j-v[j]; k <= j-1; k++) { a[i][k] = 1; } } if (v[j] > 0) { for (int k = i-h[i]; k <= i-1; k++) { a[k][j] = 1; } } } } } // Check if the solution is valid if (dp[n][m]) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccKEX1rx.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5vWWUy.o:paint.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKEX1rx.o: in function `main':
grader.cpp:(.text.startup+0x20b): undefined reference to `solve_puzzle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status