제출 #1088168

#제출 시각아이디문제언어결과실행 시간메모리
1088168quangminh412Garaža (COCI17_garaza)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; /* John Watson https://codeforces.com/profile/quangminh98 Mua Code nhu mua Florentino !! */ #define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long const int oo = 1e9; const int maxn = 3009; int n, k, q; int arr[maxn]; struct SegmentTree { struct Node { int l, r, finals; Node() = default; Node(int val) : l(val), r(val), finals(0) {} Node operator + (const Node &other) { if (l == oo) return other; if (other.l == oo) return *this; Node res; res.l = l; res.r = other.r; res.finals = max({finals, other.finals, int(r == other.l)}); return res; } }; vector<Node> st; int n; SegmentTree(int n) : n(n) { st.resize(4 * n + 5); build(1, 1, n); } void build(int head, int l, int r) { if (l == r) { st[head] = Node(arr[l]); return; } int mid = l + r >> 1; build(2 * head, l, mid); build(2 * head + 1, mid + 1, r); st[head] = st[2 * head] + st[2 * head + 1]; } Node query(int head, int l, int r, int u, int v) { if (l > v || r < u) return Node(oo); if (u <= l && r <= v) return st[head]; int mid = l + r >> 1; return query(2 * head, l, mid, u, v) + query(2 * head + 1, mid + 1, r, u, v); } int query(int u, int v) { return query(1, 1, n, u, v).finals; } }; vector<int> adj[4000]; signed main() { if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } faster(); cin >> n >> k >> q; for (int i = 1; i <= n; i++) cin >> arr[i]; if (k == 2) { SegmentTree seg(n); while (q--) { int u, v; cin >> u >> v; int ans = seg.query(u, v); cout << (ans == 1 ? "NO\n" : "YES\n"); } return 0; } SegmentTree seg(n); while (q--) { int u, v; cin >> u >> v; unordered_map<int, int> mp; int cur = 0; for (int i = u; i < v; i++) { if (mp[arr[i]] == 0) mp[arr[i]] = ++cur; if (mp[arr[i + 1]] == 0) mp[arr[i]] = ++cur; int par = i - u; if (par % 2 == 0) } } return 0; }

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

garaza.cpp: In member function 'void SegmentTree::build(int, int, int)':
garaza.cpp:54:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   54 |   int mid = l + r >> 1;
      |             ~~^~~
garaza.cpp: In member function 'SegmentTree::Node SegmentTree::query(int, int, int, int, int)':
garaza.cpp:66:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   66 |   int mid = l + r >> 1;
      |             ~~^~~
garaza.cpp: In function 'int main()':
garaza.cpp:115:3: error: expected primary-expression before '}' token
  115 |   }
      |   ^
garaza.cpp:78:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |   freopen("test.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
garaza.cpp:79:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |   freopen("test.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~