257322026-02-28 11:31:14algoproFöldönkívüli ABCcpp17Wrong answer 43/1006ms508 KiB
// UUID: 89908401-c6ad-4001-a1fc-83b4d8d067d3
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n; cin >> n;
	string s;
	for (int t = 0; t < n; t++) {
		bool fail = false;
		cin >> s;
		vector<int> alphabet(0);
		for (int i = 0; i < s.length(); i++) {
			if (count(alphabet.begin(), alphabet.end(), s[i] + 'z') > 0 || s[i] != s[i + 1]) {
				if (count(alphabet.begin(), alphabet.end(), s[i]) > 0) {
					cout << -1;
					fail = true;
					break;
				}
				alphabet.push_back(s[i]);
				continue;
			}
			alphabet.push_back(s[i] + 'z');
			i++;
		}
		if (fail) continue;
		char letter = 'a';
		for (int i : alphabet) {
			if (i > 'z') {
				letter = i - 'z';
				cout << letter << letter << ' ';
				continue;
			}
			letter = i;
			cout << letter << ' ';
		}
		cout << '\n';//count(alphabet.begin(), alphabet.end(), s[i]) > 0
	}
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms500 KiB
subtask27/7
2Accepted1ms316 KiB
subtask30/11
3Accepted1ms316 KiB
4Wrong answer1ms316 KiB
5Wrong answer1ms316 KiB
subtask413/13
6Accepted1ms316 KiB
7Accepted3ms316 KiB
8Accepted3ms508 KiB
subtask50/17
9Accepted1ms316 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Accepted3ms316 KiB
13Accepted3ms508 KiB
14Wrong answer3ms408 KiB
15Wrong answer3ms316 KiB
subtask623/23
16Accepted1ms316 KiB
17Accepted3ms316 KiB
18Accepted3ms508 KiB
19Accepted6ms316 KiB
20Accepted6ms468 KiB
21Accepted6ms412 KiB
subtask70/29
22Accepted1ms388 KiB
23Accepted1ms316 KiB
24Wrong answer1ms316 KiB
25Wrong answer1ms316 KiB
26Accepted3ms316 KiB
27Accepted3ms508 KiB
28Wrong answer3ms408 KiB
29Wrong answer3ms316 KiB
30Accepted6ms316 KiB
31Accepted6ms468 KiB
32Accepted6ms412 KiB
33Wrong answer4ms316 KiB
34Wrong answer4ms316 KiB
35Wrong answer4ms316 KiB
36Wrong answer3ms316 KiB