#include <bits/stdc++.h>
#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;
template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e5 + 10;
namespace firstSub
{
list <int> a;
int solve(int n, int m, int val, int *K, int *S, int *E)
{
int r = 0, p;
for0(pos, n)
{
a.clear();
for0(i, pos)
{
a.insert(a.end(), K[i]);
}
a.insert(a.end(), val);
for (int i = pos; i < n; i++)
{
a.insert(a.end(), K[i]);
}
int cnt = 0;
for0(i, m)
{
auto it = a.begin();
advance(it, S[i]);
int winner = 0;
bool joined = 0;
for (int j = S[i]; j <= E[i]; j++)
{
uax(winner, *it);
joined |= (*it == val);
it++;
}
if (joined)
{
if (winner == val)
{
++cnt;
}
else
{
break;
}
}
it = a.begin();
advance(it, S[i]);
for (int j = S[i]; j <= E[i]; j++)
{
if (*it < winner)
{
it = a.erase(it);
}
else
{
it++;
}
}
}
if (uax(r, cnt))
{
p = pos;
}
}
return p;
}
}
namespace secondSub
{
int solve(int n, int m, int val, int *K, int *S, int *E)
{
}
}
namespace fullSub
{
int solve(int n, int m, int val, int *K, int *S, int *E)
{
}
}
int GetBestPosition(int n, int m, int val, int *K, int *S, int *E)
{
if (n <= 500)
{
return firstSub::solve(n, m, val, K, S, E);
}
else if (n <= 5000)
{
return secondSub::solve(n, m, val, K, S, E);
}
else
{
return fullSub::solve(n, m, val, K, S, E);
}
}
Compilation message
tournament.cpp: In function 'int secondSub::solve(int, int, int, int*, int*, int*)':
tournament.cpp:107:5: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
tournament.cpp: In function 'int fullSub::solve(int, int, int, int*, int*, int*)':
tournament.cpp:115:5: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
tournament.cpp: In function 'int firstSub::solve(int, int, int, int*, int*, int*)':
tournament.cpp:98:16: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
return p;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
77 ms |
384 KB |
Output is correct |
4 |
Correct |
82 ms |
384 KB |
Output is correct |
5 |
Correct |
17 ms |
384 KB |
Output is correct |
6 |
Correct |
65 ms |
384 KB |
Output is correct |
7 |
Correct |
80 ms |
384 KB |
Output is correct |
8 |
Correct |
78 ms |
384 KB |
Output is correct |
9 |
Correct |
13 ms |
384 KB |
Output is correct |
10 |
Correct |
20 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |