QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#698912#7076. Browser Gameskouki_hashWA 2ms5976kbC++231.2kb2024-11-01 23:00:402024-11-01 23:00:41

Judging History

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

  • [2024-11-01 23:00:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5976kb
  • [2024-11-01 23:00:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct node {
	long long num;
	string s;
	long long res;
} web[50005];

bool cmp1(struct node x, struct node y) {
	if (x.s < y.s) {
		return true;
	} else {
		return false;
	}
}

bool cmp2(struct node x, struct node y) {
	if (x.num < y.num) {
		return true;
	} else {
		return false;
	}
}

int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);

	long long n;
	cin >> n;

	for (long long i = 1; i <= n; i++) {
		string temp;
		cin >> temp;

		web[i].num = i;
		web[i].s = temp;
	}

	sort(web + 1, web + 1 + n, cmp1);
	web[0].s = web[1].s, web[n + 1].s = web[n].s;

	for (long long i = 1; i <= n; i++) {
		long long tempa = 0, tempb = 0, tempc = 0, tempd = 0;
//		cout << web[i - 1].s << " " << web[i].s << " " << web[i + 1].s << "\n";
		for (long long j = 0; j < web[i].s.size(); j++) {
			if (web[i].s[j] != web[i + 1].s[j] && tempc == 0) {
				tempa = j;
				tempc = 1;
			}
			if (web[i].s[j] != web[i - 1].s[j] && tempd == 0) {
				tempb = j;
				tempd = 1;
			}
		}
		web[i].res = max(tempa + 1, tempb + 1);
	}

	sort(web + 1, web + 1 + n, cmp2);

	for (long long i = 1; i <= n; i++) {
		cout << web[i].res << "\n";
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 5916kb

input:

3
ufoipv.ofu
hsbocmvfgboubtz.kq
hfotijo.njipzp.dpn/kb

output:

1
2
2

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5976kb

input:

3
hfotijo.njipzp.dpn/kb
hsbocmvfgboubtz.kq
ufoipv.ofu

output:

2
2
1

result:

wrong answer 1st lines differ - expected: '1', found: '2'