Submission #1099864

# Submission time Handle Problem Language Result Execution time Memory
1099864 2024-10-12T05:39:10 Z model_code Hieroglyphs (IOI24_hieroglyphs) C++17
16 / 100
59 ms 21204 KB
// incorrect/yiping-n-solexist.cpp

#include<bits/stdc++.h>
#include"hieroglyphs.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

struct Data
{
	int d;
	vector<int> a, cnt, rnk;
	vector< vector<int> > pos;
	
	Data(vector<int> _a, int _d)
	{
		a = _a; d = _d;
		cnt.resize(d); pos.resize(d); rnk.resize(a.size());
		for(int i=0; i<(int)a.size(); ++i)
		{
			int x = a[i];
			rnk[i] = cnt[x]; ++cnt[x];
			pos[x].emplace_back(i);
		}
	}
	bool check(int x,int cx,int y,int cy) const
	{
		if(cx > (int)pos[x].size() || cy > (int)pos[y].size())
			return 0;
		if(cx == 0 || cy == 0) return 1;
		return pos[x][cx - 1] < pos[y][(int)pos[y].size() - cy];
	}
};

vector<int> get_cand(const Data &aa, const Data &bb)
{
	int d = aa.d;
	vector<int> type(d), need(d);
	for(int i=0; i<d; ++i)
	{
		type[i] = aa.cnt[i] <= bb.cnt[i]? 0: 1;
		need[i] = min(aa.cnt[i], bb.cnt[i]);
	}
	
	vector<pii> veca, vecb;
	for(int i=0; i<(int)aa.a.size(); ++i)
		if(type[aa.a[i]] == 0)
			veca.emplace_back(aa.a[i], aa.rnk[i]);
	for(int i=0; i<(int)bb.a.size(); ++i)
		if(type[bb.a[i]] == 1)
			vecb.emplace_back(bb.a[i], bb.rnk[i]);
	
	auto check = [&] (pii x,pii y)
	{
		return aa.check(x.first, x.second + 1, y.first, need[y.first] - y.second)
		    && bb.check(x.first, x.second + 1, y.first, need[y.first] - y.second);
	};
	
	vector<int> c;
	int i = 0, j = 0;
	while(i<(int)veca.size() && j<(int)vecb.size())
	{
		bool tx = check(veca[i], vecb[j]);
		bool ty = check(vecb[j], veca[i]);
		
		if(tx == ty) return {-1};
		
		if(tx) c.emplace_back(veca[i].first), ++i;
		else c.emplace_back(vecb[j].first), ++j;
	}
	
	while(i<(int)veca.size()) c.emplace_back(veca[i].first), ++i;
	while(j<(int)vecb.size()) c.emplace_back(vecb[j].first), ++j;
	
	return c;
}

bool is_invalid(const vector<int> &c)
{
	return c.size() == 1 && c[0] == -1;
}

vector<int> ucs(vector<int> a, vector<int> b)
{
	int d = 0;
	for(auto t: a)
		d = max(d, t + 1);
	for(auto t: b)
		d = max(d, t + 1);
	
	Data aa(a, d), bb(b, d);
	
	auto c = get_cand(aa, bb);
	if(is_invalid(c)) return c;
	
	return c;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 6216 KB Output is correct
2 Correct 26 ms 6384 KB Output is correct
3 Correct 19 ms 5644 KB Output is correct
4 Correct 18 ms 5364 KB Output is correct
5 Correct 21 ms 5784 KB Output is correct
6 Correct 9 ms 3288 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 20 ms 6212 KB Output is correct
17 Correct 16 ms 6220 KB Output is correct
18 Correct 15 ms 4164 KB Output is correct
19 Correct 11 ms 4164 KB Output is correct
20 Correct 17 ms 5200 KB Output is correct
21 Correct 13 ms 4920 KB Output is correct
22 Correct 12 ms 6076 KB Output is correct
23 Correct 13 ms 5692 KB Output is correct
24 Correct 17 ms 5712 KB Output is correct
25 Incorrect 21 ms 6216 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 6216 KB Output is correct
2 Correct 26 ms 6384 KB Output is correct
3 Correct 19 ms 5644 KB Output is correct
4 Correct 18 ms 5364 KB Output is correct
5 Correct 21 ms 5784 KB Output is correct
6 Correct 9 ms 3288 KB Output is correct
7 Correct 40 ms 20472 KB Output is correct
8 Correct 46 ms 20416 KB Output is correct
9 Correct 45 ms 20464 KB Output is correct
10 Correct 39 ms 20392 KB Output is correct
11 Correct 40 ms 20476 KB Output is correct
12 Correct 41 ms 20476 KB Output is correct
13 Correct 43 ms 20356 KB Output is correct
14 Correct 59 ms 20468 KB Output is correct
15 Correct 37 ms 20476 KB Output is correct
16 Correct 37 ms 20508 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 4 ms 12752 KB Output is correct
19 Correct 4 ms 12888 KB Output is correct
20 Correct 6 ms 13148 KB Output is correct
21 Correct 21 ms 17740 KB Output is correct
22 Correct 37 ms 21192 KB Output is correct
23 Correct 36 ms 21204 KB Output is correct
24 Correct 35 ms 21196 KB Output is correct
25 Correct 29 ms 18968 KB Output is correct
26 Correct 4 ms 12892 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 4 ms 11612 KB Output is correct
29 Correct 4 ms 12380 KB Output is correct
30 Correct 5 ms 12892 KB Output is correct
31 Correct 4 ms 12892 KB Output is correct
32 Correct 5 ms 12892 KB Output is correct
33 Correct 5 ms 13148 KB Output is correct
34 Correct 9 ms 13916 KB Output is correct
35 Correct 30 ms 18404 KB Output is correct
36 Correct 30 ms 18900 KB Output is correct
37 Correct 26 ms 18892 KB Output is correct
38 Correct 28 ms 18644 KB Output is correct
39 Correct 31 ms 18628 KB Output is correct
40 Correct 48 ms 20464 KB Output is correct
41 Correct 34 ms 18684 KB Output is correct
42 Correct 20 ms 14156 KB Output is correct
43 Correct 19 ms 15356 KB Output is correct
44 Correct 20 ms 14964 KB Output is correct
45 Correct 19 ms 13908 KB Output is correct
46 Correct 31 ms 18720 KB Output is correct
47 Correct 34 ms 18660 KB Output is correct
48 Correct 54 ms 18668 KB Output is correct
49 Correct 35 ms 18552 KB Output is correct
50 Correct 35 ms 18428 KB Output is correct
51 Correct 35 ms 18424 KB Output is correct
52 Correct 37 ms 18672 KB Output is correct
53 Correct 34 ms 18672 KB Output is correct
54 Correct 44 ms 18624 KB Output is correct
55 Correct 15 ms 14548 KB Output is correct
56 Correct 32 ms 18776 KB Output is correct
57 Correct 30 ms 18376 KB Output is correct
58 Correct 35 ms 19032 KB Output is correct
59 Correct 37 ms 18788 KB Output is correct
60 Correct 37 ms 18820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 12892 KB Output is correct
11 Correct 4 ms 12892 KB Output is correct
12 Correct 4 ms 11612 KB Output is correct
13 Correct 4 ms 12380 KB Output is correct
14 Correct 5 ms 12892 KB Output is correct
15 Correct 4 ms 12892 KB Output is correct
16 Correct 5 ms 12892 KB Output is correct
17 Correct 5 ms 13148 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 544 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Incorrect 1 ms 404 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -