# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1104074 | vjudge1 | XOR (IZhO12_xor) | C++17 | 1 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// بسم الله الرحمن الرحيم
// All praise is due to ALLAH alone
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define endl '\n'
#define exit return 0
#define ll long long int
#define ull unsigned long long int
#define read freopen ("input.txt","r",stdin);
#define write freopen ("output.txt","w",stdout);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print_vec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<' ';}cout<<"\n";
#define print_set(st) for(auto it=st.begin();it!=st.end();it++){cout<<*it<<' ';}cout<<"\n";
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define print_pair(vec) for(int i=0;i<vec.size();i++)cout<<vec[i].first<<' '<<vec[i].second<<endl;
#define dbg(num) cerr<< "Line "<<__LINE__ <<": "<< #num <<" = "<<(num)<<endl
// find_by_order() and order_of_key()
// k-th sorted element and lower_bound
//priority_queue <int, vector<int>, greater<int> > pq; **non_decreasing
//int dx[] = { -2, -2, -1, -1, 1, 1, 2, 2};
//int dy[] = { -1, 1, -2, 2, -2, 2, -1, 1};
ll lcm (ll a, ll b) {return a * (b / __gcd(a, b));}
int dx[] = { -1, 0, +1, 0};
int dy[] = {0, +1, 0, -1};
#define sz 200001
#define mod 1000000007
void solve()
{
ll n, x;
cin >> n >> x;
ll arr[n + 1];
map<ll, ll>prefix;
vector<ll>maxi(n + 1, 0);
vector<int>index(n + 1, 1e9);
ll curr = 0;
int ans = 0, start;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
curr ^= arr[i];
ll need = curr ^ x;
if (prefix[need])
{
int id = prefix[need];
if (maxi[id] > need)
{
id = index[id];
}
int len = i - id + 1;
if (len > ans)
ans = len, start = id;
}
if (prefix[curr] == 0)
prefix[curr] = i;
if (maxi[i - 1] > curr)
maxi[i] = maxi[i - 1], index[i] = index[i - 1];
else maxi[i] = curr, index[i] = i;
}
cout << start << ' ' << ans << endl;
}
int main()
{
fast;
int tc = 1;
//cin >> tc;
while (tc--)
solve();
//.............................................. ٱلْحَمْدُ لِلَّٰ......................................
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |