# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
132326 |
2019-07-18T17:27:14 Z |
anayk |
Dojave (COCI17_dojave) |
C++14 |
|
4000 ms |
29220 KB |
#include <iostream>
#define MAXN 2000000
int m, n;
int first[MAXN];
int other[MAXN];
int seq[MAXN];
long long dp[2][MAXN];
int min, max;
void add(int x)
{
min = std::min(x, min);
max = std::max(x, max);
}
void solve(int l = 0, int r = n-1)
{
int m = (l+r)/2;
int a = m;
int b = m+1;
min = a;
max = b;
add(other[seq[a]]);
add(other[seq[b]]);
while(true)
{
//std::cout << min << " " << max << " " << a << " " << b << std::endl;
if(a > min)
{
if(a == l)
break;
a--;
add(other[seq[a]]);
}
else if(b < max)
{
if(b == r)
break;
b++;
add(other[seq[b]]);
}
else
{
first[a] = std::min(first[a], b);
if(a == l)
break;
a--;
add(other[seq[a]]);
}
}
if(l == r)
return;
solve(l, m);
solve(m+1, r);
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin >> m;
n = (1 << m);
for(int i = 0; i < n; i++)
{
std::cin >> seq[i];
first[i] = MAXN;
other[seq[i]^(n-1)] = i;
}
solve();
long long answer = n;
answer *= (answer-1);
answer /= 2;
answer += (long long) n;
dp[0][n] = dp[1][n] = 0;
for(int i = n-1; i >= 0; i--)
{
dp[0][i] = dp[1][i] = 0;
if(first[i] == MAXN)
continue;
int c = first[i]-i+1;
if(c%4)
{
dp[1][i] = 1;
dp[1][i] += dp[0][first[i]+1];
dp[0][i] += dp[1][first[i]+1];
}
else
{
dp[0][i] = 1;
dp[1][i] += dp[1][first[i]+1];
dp[0][i] += dp[0][first[i]+1];
}
answer -= dp[0][i];
}
std::cout << answer << std::endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
508 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
632 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
760 KB |
Output is correct |
2 |
Correct |
5 ms |
888 KB |
Output is correct |
3 |
Correct |
5 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2140 KB |
Output is correct |
2 |
Correct |
1572 ms |
2212 KB |
Output is correct |
3 |
Correct |
27 ms |
3960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2168 KB |
Output is correct |
2 |
Execution timed out |
4016 ms |
1912 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
7704 KB |
Output is correct |
2 |
Execution timed out |
4040 ms |
3448 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
363 ms |
29056 KB |
Output is correct |
2 |
Correct |
281 ms |
29176 KB |
Output is correct |
3 |
Correct |
191 ms |
29176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
333 ms |
29220 KB |
Output is correct |
2 |
Execution timed out |
4008 ms |
12664 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |