Submission #1271191

#TimeUsernameProblemLanguageResultExecution timeMemory
1271191hoangtien69Stone Arranging 2 (JOI23_ho_t1)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int, ll> const ll MAXN = 1e5 + 5; #define ll long long map<ll, pii> segment; unordered_map<ll, set<int>> color; ll n; ll a[MAXN]; ll ans[MAXN]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { ll col = a[i]; if (i == 1) { segment[1] = {1, col}; color[col].insert(1); } else { if (color[col].empty()) { segment[i] = {i, col}; color[col].insert(i); } else { auto it = color[col].end(); it--; ll laststart = *it; ll lastend = segment[laststart].first; ll j = lastend; if (j == i - 1) { segment[laststart] = {i, col}; } else { auto pos = segment.lower_bound(j + 1); vector<ll> del; while(pos != segment.end() and pos->first <= i - 1) { del.push_back(pos->first); pos++; } for (ll start : del) { ll c2 = segment[start].second; segment.erase(start); color[c2].erase(start); } segment[j + 1] = {i, col}; color[col].insert(j + 1); } } } } for (auto cak : segment) { ll s = cak.first; ll e = cak.second.first; ll c = cak.second.second; for (ll k = s; k <= e; k++) { ans[k] = c; } } for (int i = 1; i <= n; i++) { cout << ans[i] << "\n"; } }

Compilation message (stderr)

Main.cpp:4:7: error: 'll' does not name a type
    4 | const ll MAXN = 1e5 + 5;
      |       ^~
Main.cpp:4:7: note: the macro 'll' had not yet been defined
Main.cpp:5: note: it was later defined here
    5 | #define ll long long
      | 
Main.cpp:9:6: error: 'MAXN' was not declared in this scope
    9 | ll a[MAXN];
      |      ^~~~
Main.cpp:10:8: error: 'MAXN' was not declared in this scope
   10 | ll ans[MAXN];
      |        ^~~~
Main.cpp: In function 'int main()':
Main.cpp:20:16: error: 'a' was not declared in this scope
   20 |         cin >> a[i];
      |                ^
Main.cpp:24:18: error: 'a' was not declared in this scope
   24 |         ll col = a[i];
      |                  ^
Main.cpp:76:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   76 |             ans[k] = c;
      |             ^~~
      |             abs
Main.cpp:81:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |         cout << ans[i] << "\n";
      |                 ^~~
      |                 abs