//雪花飄飄北風嘯嘯
//天地一片蒼茫
#include "grader.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << ": " << x << endl
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int MOD=998244353;
ll qexp(ll b,ll p,int m){
ll res=1;
while (p){
if (p&1) res=(res*b)%m;
b=(b*b)%m;
p>>=1;
}
return res;
}
ll inv(ll i){
return qexp(i,MOD-2,MOD);
}
ll fix(ll i){
i%=MOD;
if (i<0) i+=MOD;
return i;
}
ll fac[1000005];
ll ifac[1000005];
ll nCk(int i,int j){
if (i<j) return 0;
return fac[i]*ifac[j]%MOD*ifac[i-j]%MOD;
}
void solve(int n){
vector<int> v;
rep(x,1,n+1) v.pub(x);
shuffle(all(v),rng);
rep(x,0,min(n,n<=50?25:30)){
int pos=kth(v[x]);
if (cnt(pos)>n/3){
say_answer(pos);
return;
}
}
say_answer(-1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
200 KB |
Output is correct |
2 |
Correct |
9 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
200 KB |
Output is correct |
2 |
Correct |
24 ms |
200 KB |
Output is correct |
3 |
Correct |
11 ms |
200 KB |
Output is correct |
4 |
Correct |
9 ms |
200 KB |
Output is correct |
5 |
Correct |
24 ms |
200 KB |
Output is correct |
6 |
Correct |
33 ms |
200 KB |
Output is correct |
7 |
Correct |
23 ms |
200 KB |
Output is correct |
8 |
Correct |
25 ms |
200 KB |
Output is correct |
9 |
Correct |
16 ms |
200 KB |
Output is correct |
10 |
Correct |
25 ms |
200 KB |
Output is correct |
11 |
Correct |
31 ms |
200 KB |
Output is correct |
12 |
Correct |
32 ms |
200 KB |
Output is correct |
13 |
Correct |
26 ms |
200 KB |
Output is correct |
14 |
Correct |
30 ms |
200 KB |
Output is correct |