제출 #1259693

#제출 시각아이디문제언어결과실행 시간메모리
1259693SzymonKrzywdaAlternating Current (BOI18_alternating)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<pair<int, int>> seg(m); for (int i = 0; i < m; i++) { cin >> seg[i].ff >> seg[i].ss; } int K = 1 << m; for (int msk = 0; msk < K; msk++) { vector<vector<int>> tab(n + 1, vector<int>(2, 0)); for (int i = 0; i < m; i++) { int bit = 0; if ((1 << i) & msk) bit = 1; int a = seg[i].ff, b = seg[i].ss; if (b < a) { for (int i = a; i <= n; i++) tab[i][bit] = 1; for (int i = 1; i <= b; i++) tab[i][bit] = 1; } else for (int i = a; i <= b; i++) tab[i][bit] = 1; } bool git = 1; for (int i = 1; i <= n; i++) { if (!tab[i][0] || !tab[i][1]) git = 0; } if (git) { for (int i = 0; i < m; i++) { int bit = 0; if ((1 << i) & msk) bit = 1; cout << bit; } return 0; } } cout << "impossible\n"; return 0; }

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

alternating.cpp: In function 'int main()':
alternating.cpp:17:5: error: 'vector' was not declared in this scope
   17 |     vector<pair<int, int>> seg(m);
      |     ^~~~~~
alternating.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
alternating.cpp:17:25: error: expected primary-expression before '>' token
   17 |     vector<pair<int, int>> seg(m);
      |                         ^~
alternating.cpp:17:28: error: 'seg' was not declared in this scope
   17 |     vector<pair<int, int>> seg(m);
      |                            ^~~
alternating.cpp:25:23: error: expected primary-expression before 'int'
   25 |         vector<vector<int>> tab(n + 1, vector<int>(2, 0));
      |                       ^~~
alternating.cpp:32:17: error: 'b' was not declared in this scope
   32 |             if (b < a) {
      |                 ^
alternating.cpp:33:46: error: 'tab' was not declared in this scope
   33 |                 for (int i = a; i <= n; i++) tab[i][bit] = 1;
      |                                              ^~~
alternating.cpp:34:46: error: 'tab' was not declared in this scope
   34 |                 for (int i = 1; i <= b; i++) tab[i][bit] = 1;
      |                                              ^~~
alternating.cpp:36:47: error: 'tab' was not declared in this scope
   36 |             else for (int i = a; i <= b; i++) tab[i][bit] = 1;
      |                                               ^~~
alternating.cpp:41:18: error: 'tab' was not declared in this scope
   41 |             if (!tab[i][0] || !tab[i][1]) git = 0;
      |                  ^~~