# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
901297 | borademirtas | XOR (IZhO12_xor) | C++17 | 172 ms | 60496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#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;
#define ll long long
#define vll vector<ll>
#define pb push_back
#define vp vector<pll>
#define tc ll t; cin >> t; for(ll i = 0; i < t; i++){solve(i, t);}
#define tc1 solve(1, 1);
#define mpvll map<ll, vll>
#define vfast vll a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; }
#define mpll map<ll,ll>
#define pll pair<ll,ll>
#define vll2 vector<vector<ll>> dp(n, vector<ll>(m));
#define FIXED(A) cout << fixed; cout.precision(20); cout << A << "\n";
#define mp(A, B) make_pair(A, B)
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
#define big __int128
#define F first
#define S second
#define ckmin(a,b) a = min(a,b)
#define ckmax(a,b) a = max(a,b)
template <typename num_t>
using indexed_set = tree<num_t, null_type, less<num_t>, rb_tree_tag, tree_order_statistics_node_update>;
void setIO(string name) {freopen((name+".in").c_str(),"r",stdin);freopen((name+".out").c_str(),"w",stdout);}
ll rd(ll a, ll b){return (a+b-1) / b;}
ll isqrt(ll x){ll ans = 0; for(ll k = 1LL << 30; k != 0; k /= 2){if ((ans + k) * (ans + k) <= x) {ans += k;} } return ans; }
vll prime(ll x){ll n = x; vll ans; while (n % 2 == 0) {ans.pb(2);n = n/2;} for (int i = 3; i <= sqrt(n); i = i + 2) {while (n % i == 0){ans.pb(i);n = n/i;}}if (n > 2){ans.pb(n);} return ans;}
ll binpow(ll a, ll b, ll m) { a %= m; ll res = 1; while (b > 0) { if (b & 1){res = res * a % m;}a = a * a % m; b >>= 1;} return res;}
ll lg2(ll n){ll cnt=0;while(n){cnt++;n/=2;}return cnt;}
struct Node{
Node *c[2]; ll cnt = 2e9;
};
Node *root = new Node();
void update(ll x, ll pos){
Node *cur = root;
for(ll i = 33; i >= 0; i--){
ckmin(cur->cnt, pos);
if(x&(1LL<<i)){
if(!cur->c[1]){cur->c[1] = new Node(); cur = cur->c[1]; cur->cnt=pos; }
else{cur=cur->c[1]; }
}
else{
if(!cur->c[0]){cur->c[0] = new Node(); cur = cur->c[0]; cur->cnt=pos; }
else{cur=cur->c[0]; }
}
}
}
ll query(ll x, ll k){
Node *cur = root; ll best = 2e9;ll val = 0;
for(ll i = 33; i >= 0 ; i--){
if(cur->c[1]){
if(!(x&(1LL<<i))){
if((1LL<<i)+val >= k){ckmin(best, cur->c[1]->cnt);}
}
}
if(cur->c[0]){
if(x&(1LL<<i)){
if((1LL<<i)+val >= k){ckmin(best, cur->c[0]->cnt);}
}
}
if(((x>>i)&1LL) == ((k>>i)&1LL)){
if(cur->c[0]){
if(k&(1LL<<i)){val += (1LL<<i);}
cur = cur->c[0];
if(val>=k){ckmin(best, cur->cnt);}
}
else{
if(val>=k){ckmin(best, cur->cnt);}
return best;
}
}
else{
if(cur->c[1]){
if(k&(1LL<<i)){val += (1LL<<i);}
cur = cur->c[1];
if(val>=k){ckmin(best, cur->cnt);}
}
else{
if(val>=k){ckmin(best, cur->cnt);}
return best;
}
}
}
return best;
}
void solve(ll TC, ll TC2) {
ll n, k; cin >> n >> k;
vll a(n); for(ll i = 0; i < n; i++){cin >> a[i];}
ll pre = 0;
ll idx = -1, sz = -1;
update(0,-1);
for(ll i = 0; i < n; i++){
pre^=a[i];
ll val = query(pre,k);
if(i-val>sz){sz=i-val; idx = val+1;}
if(pre>=k){sz=i+1; idx=0;}
update(pre,i);
}
cout << idx+1 << " " << sz << '\n';
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
tc1
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |