제출 #1045942

#제출 시각아이디문제언어결과실행 시간메모리
1045942Ausp3xPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
// 人外有人,天外有天 // author: Ausp3x #pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include "paint.h" using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define pb push_back // #define DEBUG typedef long long lng; int const INF32 = 0x3f3f3f3f; lng const INF64 = 0x3f3f3f3f3f3f3f3f; string solve_puzzle(string s, vector<int> clues) {   int n = s.size(), k = clues.size();   vector<int> last_white(n + 1);   for (int i = 1; i <= n; i++) {       last_white[i] = last_white[i - 1];        if (s[i - 1] == '_')           last_white[i] = i; }   // ith cell, jth clue, end in black (0) or white (1) vector<vector<vector<bool>>> dp1(n + 1, vector<vector<bool>>(k + 1, vector<bool>(2))); dp1[0][0][1] = true; for (int i = 1; i <= n; i++) { if (s[i - 1] != 'X') for (int j = 0; j <= k; j++) dp1[i][j][1] = dp1[i - 1][j][0] | dp1[i - 1][j][1]; if (s[i - 1] != '_') for (int j = 1; j <= k; j++) if (i - clues[j - 1] >= last_white[i]) dp1[i][j][0] = dp1[i - clues[j - 1]][j - 1][1]; } int l = n + 1, r = n + 1; vector<bool> pos_black(n + 1), pos_white(n + 1); vector<vector<vector<bool>>> dp2(n + 1, vector<vector<bool>>(k + 1, vector<bool>(2))); dp2[n][k][0] = dp2[n][k][1] = true; for (int i = n; i > 0; i--) for (int j = 0; j <= k; j++) { if (dp1[i][j][0] && dp2[i][j][0]) { if (i < l) { l = r = i; pos_black[i] = true; } if (j > 0) if (i - clues[j - 1] >= 0) { while (i - clues[j - 1] + 1 < l) { l--; pos_black[l] = true; } dp2[i - clues[j - 1]][j - 1][1] = 1; } } if (dp1[i][j][1] && dp2[i][j][1]) { pos_white[i] = true; dp2[i - 1][j][0] = dp2[i - 1][j][1] = true; } } string t; for (int i = 1; i <= n; i++) if (pos_black[i] && pos_white[i]) t += '?'; else if (pos_black[i]) t += 'X'; else if (pos_white[i]) t += '_'; else t += '.'; return t; } #ifdef DEBUG int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; cin >> t; while (t--) { string s; int k; cin >> s >> k; vector<int> clues(k); for (int &c : clues) cin >> c; cout << solve_puzzle(s, clues) << endl; } return 0; } #endif

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp:21:2: error: extended character   is not valid in an identifier
   21 |     int n = s.size(), k = clues.size();
      |  ^
paint.cpp:22:2: error: extended character   is not valid in an identifier
   22 |     vector<int> last_white(n + 1);
      |  ^
paint.cpp:23:2: error: extended character   is not valid in an identifier
   23 |     for (int i = 1; i <= n; i++) {
      |  ^
paint.cpp:24:2: error: extended character   is not valid in an identifier
   24 |         last_white[i] = last_white[i - 1];
      |  ^
paint.cpp:24:5: error: extended character   is not valid in an identifier
   24 |         last_white[i] = last_white[i - 1];
      |    ^
paint.cpp:24:8: error: extended character   is not valid in an identifier
   24 |         last_white[i] = last_white[i - 1];
      |      ^
paint.cpp:25:2: error: extended character   is not valid in an identifier
   25 |         if (s[i - 1] == '_')
      |  ^
paint.cpp:25:5: error: extended character   is not valid in an identifier
   25 |         if (s[i - 1] == '_')
      |    ^
paint.cpp:25:8: error: extended character   is not valid in an identifier
   25 |         if (s[i - 1] == '_')
      |      ^
paint.cpp:25:11: error: extended character   is not valid in an identifier
   25 |         if (s[i - 1] == '_')
      |        ^
paint.cpp:26:2: error: extended character   is not valid in an identifier
   26 |             last_white[i] = i;
      |  ^
paint.cpp:26:5: error: extended character   is not valid in an identifier
   26 |             last_white[i] = i;
      |    ^
paint.cpp:26:8: error: extended character   is not valid in an identifier
   26 |             last_white[i] = i;
      |      ^
paint.cpp:26:11: error: extended character   is not valid in an identifier
   26 |             last_white[i] = i;
      |        ^
paint.cpp:26:14: error: extended character   is not valid in an identifier
   26 |             last_white[i] = i;
      |          ^
paint.cpp:29:2: error: extended character   is not valid in an identifier
   29 |     // ith cell, jth clue, end in black (0) or white (1)
      |  ^
paint.cpp:4:55: warning: bad option '-f O2' to pragma 'optimize' [-Wpragmas]
    4 | #pragma GCC optimize("O1, O2, O3, Ofast, unroll-loops")
      |                                                       ^
paint.cpp:4:55: warning: bad option '-f O3' to pragma 'optimize' [-Wpragmas]
paint.cpp:4:55: warning: bad option '-f Ofast' to pragma 'optimize' [-Wpragmas]
paint.cpp:4:55: warning: bad option '-f unroll-loops' to pragma 'optimize' [-Wpragmas]
In file included from paint.cpp:7:
paint.h:6:59: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
    6 | std::string solve_puzzle(std::string s, std::vector<int> c);
      |                                                           ^
paint.h:6:59: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
paint.h:6:59: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
paint.cpp:20:48: warning: bad option '-f O2' to attribute 'optimize' [-Wattributes]
   20 | string solve_puzzle(string s, vector<int> clues) {
      |                                                ^
paint.cpp:20:48: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
paint.cpp:20:48: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
paint.cpp:20:48: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:21:2: error: '\U000000a0' was not declared in this scope
   21 |     int n = s.size(), k = clues.size();
      |  ^
paint.cpp:22:4: error: expected ';' before 'vector'
   22 |     vector<int> last_white(n + 1);
      |   ^ ~~~~~~
      |   ;
paint.cpp:23:4: error: expected ';' before 'for'
   23 |     for (int i = 1; i <= n; i++) {
      |   ^ ~~~
      |   ;
paint.cpp:23:22: error: 'i' was not declared in this scope
   23 |     for (int i = 1; i <= n; i++) {
      |                     ^
paint.cpp:23:27: error: 'n' was not declared in this scope
   23 |     for (int i = 1; i <= n; i++) {
      |                          ^
paint.cpp:29:4: error: expected ';' before 'vector'
   29 |     // ith cell, jth clue, end in black (0) or white (1)
      |   ^
      |   ;
   30 |  vector<vector<vector<bool>>> dp1(n + 1, vector<vector<bool>>(k + 1, vector<bool>(2)));
      |  ~~~~~~
paint.cpp:31:2: error: 'dp1' was not declared in this scope
   31 |  dp1[0][0][1] = true;
      |  ^~~
paint.cpp:34:25: error: 'k' was not declared in this scope
   34 |    for (int j = 0; j <= k; j++)
      |                         ^
paint.cpp:38:25: error: 'k' was not declared in this scope
   38 |    for (int j = 1; j <= k; j++)
      |                         ^
paint.cpp:39:29: error: 'last_white' was not declared in this scope
   39 |     if (i - clues[j - 1] >= last_white[i])
      |                             ^~~~~~~~~~
paint.cpp:45:63: error: 'k' was not declared in this scope
   45 |  vector<vector<vector<bool>>> dp2(n + 1, vector<vector<bool>>(k + 1, vector<bool>(2)));
      |                                                               ^
paint.cpp:51:12: error: 'r' was not declared in this scope
   51 |        l = r = i;
      |            ^
paint.cpp:73:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   73 |     for (int i = 1; i <= n; i++)
      |     ^~~
paint.cpp:82:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   82 |  return t;
      |  ^~~~~~