Submission #1143542

#TimeUsernameProblemLanguageResultExecution timeMemory
1143542SangSequence (APIO23_sequence)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() #define task "kbsiudthw" typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<int, ii> pii; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 2277; namespace sub1{ ii findMedian(vi A){ sort(ALL(A)); int k = (int)A.size() - 1; return {A[k/2], A[(k+1)/2]}; } int solve(int N, vi A){ vi cnt(N+1, 0); int ans = 0; FOR (i, 0, N-1){ vi vec; FOR (j, i, N-1){ cnt[A[j]]++; vec.pb(A[j]); ii med = findMedian(vec); ans = max(ans, cnt[med.fi]); ans = max(ans, cnt[med.se]); } FOR (j, i, N-1) cnt[A[j]]--; } return ans; } } namespace sub2{ int solve(int N, vi A){ vi cnt(N+1, 0); int ans = 0; FOR (i, 0, N-1){ ordered_multiset<int> X; FOR (j, i, N-1){ X.insert(A[j]); ++cnt[A[j]]; int s = j - i; ii med = {*X.find_by_order(s/2), *X.find_by_order((s+1)/2)}; ans = max(ans, cnt[med.fi]); ans = max(ans, cnt[med.se]); } FOR (j, i, N-1) cnt[A[j]]--; } return ans; } } int sequence(int N, std::vector<int> A){ if (N <= 100) return sub1::solve(N, A); else if (N <= 2000) return sub2::solve(N, A); } signed main(){ return 0; }

Compilation message (stderr)

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
   76 | }
      | ^
/usr/bin/ld: /tmp/cc6iIGjo.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGJLYuW.o:sequence.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status