# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485993 |
2021-11-10T06:01:39 Z |
blue |
Minerals (JOI19_minerals) |
C++17 |
|
26 ms |
3416 KB |
#include "minerals.h"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
using vi = vector<int>;
const int maxN = 43'000;
int N;
vi mushroom(1+2*maxN, 0);
void dnc(vi L, vi R)
{
// cerr << "dnc ";
// for(int l:L) cerr << l << ' ';
// cerr << " | ";
// for(int r:R) cerr << r << ' ';
// cerr << "\n";
if(int(L.size()) == 1)
Answer(L[0], R[0]);
else
{
int K = int(L.size());
vi L1, L2;
for(int i = 0; i < K/2; i++)
L1.push_back(L[i]);
for(int i = K/2; i < K; i++)
L2.push_back(L[i]);
int Q;
for(int l: L1)
Q = Query(l); //enable
vi R1, R2;
for(int r:R)
{
int Q1 = Query(r);
if(Q1 == Q)
{
R1.push_back(r);
}
else
{
R2.push_back(r);
}
Q1 = Query(r);
}
for(int l: L1)
Q = Query(l);
dnc(L1, R1);
dnc(L2, R2);
}
}
void Solve(int N_)
{
N = N_;
int ct = 0;
for(int i = 1; i <= 2*N; i++)
{
int Q = Query(i);
if(Q > ct)
{
// cerr << "increasing ct = " << ct << " at " << i << '\n';
ct++;
mushroom[i] = ct;
// cerr << i << " : " << mushroom[i] << '\n';
}
}
for(int i = 1; i <= 2*N; i++) Query(i);
// cerr << "check\n";
// for(int i = 1; i <= 2*N; i++) cerr << i << " : " << mushroom[i] << '\n';
vi leftval, rightval;
for(int i = 1; i <= 2*N; i++)
{
if(mushroom[i])
leftval.push_back(i);
else
rightval.push_back(i);
}
dnc(leftval, rightval);
}
Compilation message
minerals.cpp: In function 'void dnc(vi, vi)':
minerals.cpp:45:13: warning: 'Q' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | if(Q1 == Q)
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
712 KB |
Output is correct |
2 |
Correct |
2 ms |
712 KB |
Output is correct |
3 |
Correct |
4 ms |
840 KB |
Output is correct |
4 |
Correct |
7 ms |
1096 KB |
Output is correct |
5 |
Correct |
15 ms |
1608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
584 KB |
Output is correct |
2 |
Correct |
0 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
584 KB |
Output is correct |
4 |
Correct |
0 ms |
584 KB |
Output is correct |
5 |
Correct |
1 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
840 KB |
Output is correct |
8 |
Correct |
7 ms |
1096 KB |
Output is correct |
9 |
Correct |
15 ms |
1608 KB |
Output is correct |
10 |
Correct |
1 ms |
712 KB |
Output is correct |
11 |
Correct |
10 ms |
1364 KB |
Output is correct |
12 |
Correct |
16 ms |
1656 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
15 ms |
1608 KB |
Output is correct |
15 |
Incorrect |
26 ms |
3416 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |