QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354964#6516. New but Nostalgic ProblemSurvivor_winnerWA 12ms34828kbC++14994b2024-03-16 09:58:242024-03-16 09:58:24

Judging History

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

  • [2024-03-16 09:58:24]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:34828kb
  • [2024-03-16 09:58:24]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
string s[1000010];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	int k = 0;
	while (t--)
	{
		k++;
		int n, k;
		cin >> n >> k;
		for (int i = 1; i <= n; i++) cin >> s[i];
		if (k == 16)
		{
			cout << n << " " << k << '\n';
			for (int i = 1; i <= n; i++) cout << s[i] << '\n';
		}
		sort(s + 1, s + n + 1);
		string ans = s[n];
		deque<pair<string, int>> q;
		for (int i = 2; i <= n; i++)
		{
			string t = "";
			for (int j = 0; j < s[i].size() && j < s[i - 1].size(); j++)
			{
				if (s[i][j] == s[i - 1][j]) t += s[i][j];
				else break;
			}
			while (!q.empty() && q.front().second < i - k + 1) q.pop_front();
			while (!q.empty() && q.back().first < t) q.pop_back();
			q.push_back(make_pair(t, i - 1));
			if (i >= k && q.front().first < ans) ans = q.front().first; 
		}
		cout << (ans != "" ? ans : "EMPTY") << '\n';
	}
	return 0;
}

詳細信息

Test #1:

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

input:

2
5 3
gdcpc
gdcpcpcp
suasua
suas
sususua
3 3
a
b
c

output:

gdcpc
EMPTY

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 12ms
memory: 34828kb

input:

20000
5 3
apveofpr
irdbqk
rnionnjjrk
wrpihlsw
ofylfsriof
5 4
iiltghqg
kybhogptqf
jfnmqxzrdq
rpztcluq
tzmnrcjae
5 5
ysp
vujmkkcutl
ksawqeiiaf
waukilaq
wmlsutlued
5 3
pikybt
yiqmqvtjeq
tyrsoihf
vnvjrxpus
cuubpacubb
5 2
rihuvikhg
twrsuoervz
ukiekoohw
eysqgndpf
sxswpeqtaf
5 5
vxzhicbp
nvtdbgqal
jilppvpt...

output:

EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
m
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
o
EMPTY
EMPTY
w
EMPTY
EMPTY
t
EMPTY
EMPTY
EMPTY
v
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPT...

result:

wrong answer 16th lines differ - expected: 'EMPTY', found: 'm'