제출 #1170914

#제출 시각아이디문제언어결과실행 시간메모리
1170914JelalTkm무지개나라 (APIO17_rainbow)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "rainbow.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; // #define int long long int const int Nqwe = 2e5 + 10; // const int md = 1e9 + 7; // const int INF = 1e18; vector<vector<int>> a(60, vector<int> (2e5 + 10)); vector<int> pref(2e5 + 10), pref1(2e5 + 10), pref2(2e5 + 10); vector<bool> ok(2e5 + 10), ok1(2e5 + 10), ok2(2e5 + 10); bool visited[60][Nqwe]; bool ok = 0; bool check(int x1, int y1, int x2, int y2, int x, int y) { return (x >= x1 && x <= x2 && y >= y1 && y <= y2); } int colour(int x1, int y1, int x2, int y2) { if (!ok) { memset(visited, 0, sizeof visited); int ans = 0; for (int i = x1; i <= x2; i++) { for (int j = y1; j <= y2; j++) { if (!visited[i][j] && !a[i][j]) { ans++; queue<pair<int, int>> q; q.push({i, j}); while (!q.empty()) { auto [u, v] = q.front(); q.pop(); if (check(x1, y1, x2, y2, u + 1, v) && !a[u + 1][v]) { visited[u + 1][v] = 1; q.push({u + 1, v}); } if (check(x1, y1, x2, y2, u - 1, v) && !a[u - 1][v]) { visited[u - 1][v] = 1; q.push({u - 1, v}); } if (check(x1, y1, x2, y2, u, v + 1) && !a[u][v + 1]) { visited[u][v + 1] = 1; q.push({u, v + 1}); } if (check(x1, y1, x2, y2, u, v - 1) && !a[u][v - 1]) { visited[u][v - 1] = 1; q.push({u, v - 1}); } } } } } return ans; } else { if (x1 != x2) { return (pref[y2] - pref[y1 - 1] + ((!a[x1][y2] | !a[x2][y2])) - ok[y1]); } else if (x1 == 1) { return (pref1[y2] - pref1[y1 - 1] + (!a[x1][y2]) - ok1[y1]); } else return (pref2[y2] - pref2[y2 - 1] + (!a[x1][y2]) - ok2[y1]); } return 0; } void init(int n, int m, int x, int y, int c, char *s) { if (n == 2) ok = 1; a[x][y] = 1; for (int i = 0; i < c; i++) { if (s[i] == 'N') x--; if (s[i] == 'S') x++; if (s[i] == 'W') y--; if (s[i] == 'E') y++; a[x][y] = 1; } if (ok) { for (int i = 1; i <= m; i++) { pref[i] = pref[i - 1]; pref1[i] = pref1[i - 1]; pref2[i] = pref2[i - 1]; if (a[1][i] == 1 && a[2][i] == 1 && (i > 1 && (!a[1][i - 1] || !a[2][i - 1]))) pref[i]++, ok[i] = 1; if (a[1][i] == 1 && (i > 1 && !a[1][i - 1])) pref1[i]++, ok1[i] = 1; if (a[2][i] == 1 && (i > 1 && !a[2][i - 1])) pref2[i]++, ok2[i] = 1; } } return; } // int32_t main(int32_t argc, char *argv[]) { // ios::sync_with_stdio(false); // cin.tie(nullptr); // int T = 1; // // cin >> T; // while (T--) { // } // return 0; // }

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

rainbow.cpp:18:6: error: conflicting declaration 'bool ok'
   18 | bool ok = 0;
      |      ^~
rainbow.cpp:16:14: note: previous declaration as 'std::vector<bool> ok'
   16 | vector<bool> ok(2e5 + 10), ok1(2e5 + 10), ok2(2e5 + 10);
      |              ^~
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:25:7: error: no match for 'operator!' (operand type is 'std::vector<bool>')
   25 |   if (!ok) {
      |       ^~~
rainbow.cpp:25:7: note: candidate: 'operator!(bool)' (built-in)
rainbow.cpp:25:7: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'bool'
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:71:10: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'int')
   71 |     ok = 1;
      |          ^
In file included from /usr/include/c++/11/vector:68,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from rainbow.cpp:1:
/usr/include/c++/11/bits/stl_bvector.h:736:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  736 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:736:31: note:   no known conversion for argument 1 from 'int' to 'const std::vector<bool>&'
  736 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_bvector.h:767:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  767 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:767:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<bool>&&'
  767 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_bvector.h:792:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  792 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:792:40: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<bool>'
  792 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~
rainbow.cpp:81:7: error: could not convert 'ok' from 'std::vector<bool>' to 'bool'
   81 |   if (ok) {
      |       ^~
      |       |
      |       std::vector<bool>