Submission #55158749
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
:- module main.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string.
:- import_module list.
:- import_module int.
:-pred read_line_as_string_det(string::out, io::di, io::uo) is det.
read_line_as_string_det(Res, IO1, IO2) :-
read_line_as_string(Read, IO1, IO2),
(
Read = ok(Str),
Res = Str
;
Read = error(Err),
Res = ""
;
Read = eof,
Res = ""
).
:-pred to_int_det(string::in, int::out) is det.
to_int_det(Str, Int) :-
(
if to_int(Str, Int_imm)
then Int = Int_imm
else Int = 0
).
:-pred index0_det(list(T)::in, int::in, T::in, T::out) is det.
index0_det(List, Idx, Default, Item) :-
(
if index0(List, Idx, Item_imm)
then Item = Item_imm
else Item = Default
).
main(IO1, IO5) :-
read_line_as_string_det(Line1, IO1, IO2),
read_line_as_string_det(Line2, IO2, IO3),
read_line_as_string_det(Line3, IO3, IO4),
A_str = strip(Line1),
BC = words(strip(Line2)),
index0_det(BC, 0, "", B_str),
index0_det(BC, 1, "", C_str),
to_int_det(A_str, A),
to_int_det(B_str, B),
to_int_det(C_str, C),
Sum = A + B + C,
write_string(from_int(Sum) ++ " " ++ Line3, IO4, IO5).
:- end_module main.
Submission Info
Submission Time |
|
Task |
PracticeA - Welcome to AtCoder |
User |
mikecat |
Language |
Mercury (Mercury 22.01.6) |
Score |
100 |
Code Size |
1284 Byte |
Status |
AC |
Exec Time |
33 ms |
Memory |
40600 KB |
Compile Error
main.m:019: In clause for predicate `read_line_as_string_det'/3:
main.m:019: warning: variable `Err' occurs only once in this scope.
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_rnd_01.txt, 00_rnd_02.txt, 00_rnd_03.txt, 00_rnd_04.txt, 00_rnd_05.txt, 00_sample_1.txt, 00_sample_2.txt |
Case Name |
Status |
Exec Time |
Memory |
00_rnd_01.txt |
AC |
33 ms |
40392 KB |
00_rnd_02.txt |
AC |
16 ms |
40336 KB |
00_rnd_03.txt |
AC |
16 ms |
40504 KB |
00_rnd_04.txt |
AC |
15 ms |
40512 KB |
00_rnd_05.txt |
AC |
15 ms |
40396 KB |
00_sample_1.txt |
AC |
16 ms |
40504 KB |
00_sample_2.txt |
AC |
16 ms |
40600 KB |