QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77589#5499. AliasesXKErrorWA 191ms20292kbC++971b2023-02-15 09:45:532023-02-15 09:45:57

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-15 09:45:57]
  • 评测
  • 测评结果:WA
  • 用时:191ms
  • 内存:20292kb
  • [2023-02-15 09:45:53]
  • 提交

answer

#include <bits/stdc++.h>

#define maxn 200005

using namespace std;

int n;
int lg[maxn];
string x[maxn];
string y[maxn];

unordered_map<string, int> mp;

struct node{
	int a, b, c;
	bool operator < (const node x) const {
		return a + b + c < x.a + x.b + x.c;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	for (int i = 1; i < maxn; i++) lg[i] = lg[i / 10] + 1;
	int T;
	cin >> T;
	while (T--) {
		cin >> n;
		node ans = {0, 0, lg[n]};
//		node ans = {11, 11, 11};
		for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
		for (int a = 0; a <= 6; a++) {
			for (int b = 0; a + b <= 6; b++) {
				if (a + b == 0) continue;
				for (int i = 1; i <= n; i++) {
					++mp[x[i].substr(0, a) + y[i].substr(0, b)];
				}
				node res = {0, 0, 0};
				for (auto p : mp) res = max(res, {a, b, lg[p.second]});
				ans = min(ans, res);
				mp.clear();
			}
		}
		printf("%d %d %d\n", ans.a, ans.b, ans.c);
	}
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 16896kb

input:

1
11
sven eriksson
erik svensson
sven svensson
erik eriksson
bjorn eriksson
bjorn svensson
bjorn bjornsson
erik bjornsson
sven bjornsson
thor odinsson
odin thorsson

output:

0 0 2

result:

ok correct! (1 test case)

Test #2:

score: 0
Accepted
time: 33ms
memory: 17764kb

input:

6
1
g u
14643
gj ek
hc bi
hi ke
ab ij
hk cj
ha bi
ag fe
eb ej
hd ei
bf gj
ke dd
ib jd
id jb
gd ei
cj bi
bi hg
ic dh
ke gk
af eg
fg dd
fe fa
be ge
hf kj
ih ci
gg jf
ed dd
eh gi
cc kd
ka fd
af gb
ka fe
ja ed
bc hi
eg cf
gg ff
kf gf
ii ch
hh ec
ei ec
cd gc
bh hb
dd id
ce bk
ib ic
bf kk
gh cd
hb he
if g...

output:

0 0 1
0 0 5
0 1 1
1 0 2
1 1 1
2 0 1

result:

ok correct! (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 191ms
memory: 20292kb

input:

6
5000
dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...

output:

0 0 4
0 1 3
1 1 2
2 0 2
1 2 1
0 0 5

result:

wrong answer Rozwiazanie nieoptymalne! (test case 6)