Submission #1287857

#TimeUsernameProblemLanguageResultExecution timeMemory
1287857KickingKunBubble Sort 2 (JOI18_bubblesort2)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define bigint __int128 #define emb emplace_back #define pb push_back #define pii pair <int, int> #define fi first #define se second #define all(v) v.begin(), v.end() #define Task "" #define MASK(k) (1ull << k) #define bitcnt(k) __builtin_popcount(k) #define testBit(n, k) ((n >> k) & 1) #define flipBit(n, k) (n ^ (1ll << k)) #define offBit(n, k) (n & ~MASK(k)) #define onBit(n, k) (n | (1ll << k)) template <class T> bool minimize(T &a, T b) {if (a > b) {a = b; return true;} return false;} template <class T> bool maximize(T &a, T b) {if (a < b) {a = b; return true;} return false;} const int N = 2e5 + 5, lim = 60, mod = 1e9 + 7; const ll INF = 1e18; int n, q, a[N]; namespace sub2 { void solve() { for (int _ = 1; _ <= q; _++) { a[x[i]] = v[i]; vector <int> b(a, a + n + 1); sort (b.begin() + 1, b.end()); int ans = 0; for (int i = 1; i <= n; i++) { int k = upper_bound(b.begin() + 1, b.end(), a[i]) - b.begin() - 1; maximize(ans, i - k); } cout << ans << '\n'; } } } namespace sub3 { void solve() { } } namespace sub4 { void solve() { } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < q; i++) cin >> x[i] >> v[i], ++x[i]; if (max(n, q) <= 8e3) sub2::solve(); else if (max(*max_element(a + 1, a + n + 1), *max_element(v, v + q)) <= 100) sub3::solve(); else sub4::solve(); }

Compilation message (stderr)

bubblesort2.cpp: In function 'void sub2::solve()':
bubblesort2.cpp:34:27: error: 'x' was not declared in this scope
   34 |                         a[x[i]] = v[i];
      |                           ^
bubblesort2.cpp:34:29: error: 'i' was not declared in this scope
   34 |                         a[x[i]] = v[i];
      |                             ^
bubblesort2.cpp:34:35: error: 'v' was not declared in this scope
   34 |                         a[x[i]] = v[i];
      |                                   ^
bubblesort2.cpp: In function 'int main()':
bubblesort2.cpp:73:24: error: 'x' was not declared in this scope
   73 |                 cin >> x[i] >> v[i], ++x[i];
      |                        ^
bubblesort2.cpp:73:32: error: 'v' was not declared in this scope
   73 |                 cin >> x[i] >> v[i], ++x[i];
      |                                ^
bubblesort2.cpp:76:67: error: 'v' was not declared in this scope
   76 |         else if (max(*max_element(a + 1, a + n + 1), *max_element(v, v + q)) <= 100)
      |                                                                   ^
bubblesort2.cpp:64:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |                 freopen(Task".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bubblesort2.cpp:65:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |                 freopen(Task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~