이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |