Submission #994339

# Submission time Handle Problem Language Result Execution time Memory
994339 2024-06-07T12:06:35 Z prvocislo Minerals (JOI19_minerals) C++17
85 / 100
26 ms 2848 KB
#include "minerals.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;

vector<int> h1, h2;
int c = 0; // kolko z h1 je vnutri?
int lst = 0; 
bool other(int x) // je druhy prvok typu x vnutri?
{
	int now = Query(x);
	if (now != lst) return lst = now, false;
	return lst = now, true;
}
void go(int c2)
{
	while (c > c2) lst = Query(h1[--c]);
	while (c < c2) lst = Query(h1[c++]);
}
void solve(int l, int r, vector<int> b)
{
	if (l == r)
	{
		Answer(h1[l - 1], b[0]);
		return;
	}
	int m = (l + r) / 2;
	go(m);
	vector<int> bl, br;
	for (int i : b)
	{
		if (bl.size() == m - l + 1)
		{
			br.push_back(i);
		}
		else if (br.size() == r - m)
		{
			bl.push_back(i);
		}
		else
		{
			if (other(i)) bl.push_back(i);
			else br.push_back(i);
		}
	}
	solve(l, m, bl);
	solve(m + 1, r, br);
}
void Solve(int n) 
{
	for (int i = 1; i <= 2 * n; i++)
	{
		if (other(i)) h2.push_back(i);
		else h1.push_back(i), c++;
	}
	solve(1, n, h2);
}

Compilation message

minerals.cpp: In function 'void solve(int, int, std::vector<int>)':
minerals.cpp:46:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   if (bl.size() == m - l + 1)
      |       ~~~~~~~~~~^~~~~~~~~~~~
minerals.cpp:50:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   else if (br.size() == r - m)
      |            ~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 8 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
19 Correct 23 ms 2524 KB Output is correct
20 Correct 19 ms 2648 KB Output is correct
21 Correct 16 ms 2516 KB Output is correct
22 Correct 14 ms 2308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
19 Correct 23 ms 2524 KB Output is correct
20 Correct 19 ms 2648 KB Output is correct
21 Correct 16 ms 2516 KB Output is correct
22 Correct 14 ms 2308 KB Output is correct
23 Correct 20 ms 2648 KB Output is correct
24 Correct 21 ms 2648 KB Output is correct
25 Correct 15 ms 2452 KB Output is correct
26 Correct 14 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
19 Correct 23 ms 2524 KB Output is correct
20 Correct 19 ms 2648 KB Output is correct
21 Correct 16 ms 2516 KB Output is correct
22 Correct 14 ms 2308 KB Output is correct
23 Correct 20 ms 2648 KB Output is correct
24 Correct 21 ms 2648 KB Output is correct
25 Correct 15 ms 2452 KB Output is correct
26 Correct 14 ms 2392 KB Output is correct
27 Correct 23 ms 2648 KB Output is correct
28 Correct 21 ms 2648 KB Output is correct
29 Correct 15 ms 2668 KB Output is correct
30 Correct 16 ms 2472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
19 Correct 23 ms 2524 KB Output is correct
20 Correct 19 ms 2648 KB Output is correct
21 Correct 16 ms 2516 KB Output is correct
22 Correct 14 ms 2308 KB Output is correct
23 Correct 20 ms 2648 KB Output is correct
24 Correct 21 ms 2648 KB Output is correct
25 Correct 15 ms 2452 KB Output is correct
26 Correct 14 ms 2392 KB Output is correct
27 Correct 23 ms 2648 KB Output is correct
28 Correct 21 ms 2648 KB Output is correct
29 Correct 15 ms 2668 KB Output is correct
30 Correct 16 ms 2472 KB Output is correct
31 Incorrect 26 ms 2848 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 4 ms 856 KB Output is correct
9 Correct 8 ms 1204 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 5 ms 1032 KB Output is correct
12 Correct 8 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 5 ms 1212 KB Output is correct
15 Correct 21 ms 2528 KB Output is correct
16 Correct 19 ms 2636 KB Output is correct
17 Correct 16 ms 2516 KB Output is correct
18 Correct 13 ms 2292 KB Output is correct
19 Correct 23 ms 2524 KB Output is correct
20 Correct 19 ms 2648 KB Output is correct
21 Correct 16 ms 2516 KB Output is correct
22 Correct 14 ms 2308 KB Output is correct
23 Correct 20 ms 2648 KB Output is correct
24 Correct 21 ms 2648 KB Output is correct
25 Correct 15 ms 2452 KB Output is correct
26 Correct 14 ms 2392 KB Output is correct
27 Correct 23 ms 2648 KB Output is correct
28 Correct 21 ms 2648 KB Output is correct
29 Correct 15 ms 2668 KB Output is correct
30 Correct 16 ms 2472 KB Output is correct
31 Incorrect 26 ms 2848 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -