QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676961#7698. ISBN Conversionnew_game_plus_players#WA 0ms3792kbC++141.1kb2024-10-26 06:35:522024-10-26 06:35:52

Judging History

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

  • [2024-10-26 06:35:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-10-26 06:35:52]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
bool solve() {
	string s;
	cin>>s;
	vector<int> h, v;
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='-') {
			h.PB(i);
		} else {
			v.PB(s[i]=='X' ? 10 : s[i]-'0');
		}
		if (s[i]=='X' && i+1 < s.size()) return false;
	}
	if (h.size() > 3) return false;
	if (h.size()==3 && h[2] != s.size()-2) return false;
	if (h.size()>0 && h[0] == 0) return false;
	if (h.size()>0 && h.back() ==s.size()-1) return false;
	for (int i=1; i<h.size(); i++) {
		if (h[i-1] + 1 == h[i]) return false;
	}
	if (v.size() != 10) return false;
	int sum = 0;
	for (int i=0; i<10; i++) {
		sum += (10-i) * v[i];
	}
	if (sum%11 != 0) return false;
	sum = 9 + 7 * 3 + 8;
	for (int i=0; i<9; i++) {
		sum += (3 - (i%2)*2) * v[i];
	}
	int cs = 10 - sum % 10;
	string t = "978-";
	t = t + s;
	t[t.size()-1] = '0' + cs;
	cout<<t<<endl;
	return true;
}

int main() {
	int Tn;
	cin>>Tn;
	while (Tn--) {
		if (!solve()) {
			puts("invalid");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

4
3-540-4258-02
039428013X
3-540-42580-2
0-14-028333-3

output:

invalid
978-0394280134
978-3-540-42580-9
invalid

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

25
----------
-----------
------------
-------------
XXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXXX
---------X
----------X
-----------X
01234567890
012345678901
0123456789012
-0123456789-
0123456789-
-0123456789
01--23456789
012345678--9
0123456789--
--0123456789
98765432-1
987-654-321
87-645-32-...

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 25 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

5
71234567X1
71234567X-1
2-2345678-9
8X-7X-123456
7123X8123X

output:

invalid
invalid
invalid
invalid
invalid

result:

ok 5 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

10
3-540-42580-X
3-540-42580-3
0393609394
0-19-853453-9
0070131510
0070131512
0070131514
0070131516
0070131518
007013151X

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 10 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

11
767-13423100
65955-01-15-1
778592-4222
3283-138-073
8-802896-37-4
514-2481525
356-52708-6-6
4-810-73599-7
3-28438-244-8
1-98-2031209
82-54-55344X

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 11 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

12
0123456789
0-19-853453-1
0070131511
0-07-0131511
039428013-X
0-39-428013X
0-3942801-3X
0131103628
3-540-42580-2
3540425802
1535956828
1535-9-5682-8

output:

978-0123456786
978-0-19-853453-2
978-0070131514
978-0-07-0131514
978-039428013-4
978-0-39-4280134
978-0-3942801-34
978-0131103627
978-3-540-42580-9
978-3540425809
978-1535956826
978-1535-9-5682-6

result:

ok 12 lines

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3704kb

input:

10
69289-01810
07-8-2406750
4946302-980
91-45-00652-0
2526831830
8370591930
022-18967-4-0
86340-22-25-0
862-57-6642-0
1691783730

output:

978-69289-0181:
978-07-8-2406757
978-4946302-985
978-91-45-00652-8
978-2526831832
978-8370591939
978-022-18967-4-3
978-86340-22-25-4
978-862-57-6642-6
978-1691783731

result:

wrong answer 1st lines differ - expected: '978-69289-01810', found: '978-69289-0181:'