Task: | Kayaks |
Sender: | Olli-Pekka Lindström |
Submission time: | 2015-09-09 17:25:12 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.06 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | WRONG ANSWER | 0.06 s | details |
#5 | WRONG ANSWER | 0.06 s | details |
#6 | WRONG ANSWER | 0.06 s | details |
#7 | WRONG ANSWER | 0.06 s | details |
#8 | WRONG ANSWER | 0.05 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | WRONG ANSWER | 0.06 s | details |
#11 | WRONG ANSWER | 0.05 s | details |
#12 | WRONG ANSWER | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:34:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] (void) scanf("%d %d", &h, &w); ^ input/code.cpp:42:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", tmp); ^
Code
#include <cstdio> #include <cstring> int findint(char* s){ while(*s != 0x00){ if(*s <= '9' && *s > '0') return *s-'0'; s++; } return -1; } int get_dist(char* s){ int i=0; while(*s != 0x00){ if(*s <= '9' && *s > '0') return i; s++; i++; } return -1; } int get_max(int* dists){ int i; int max = 0; for(i=0; i<9; i++){ if(dists[i] > max) max = dists[i]; } return max; } int main(){ int w,h; (void) scanf("%d %d", &h, &w); char raw[h][w+1]; int i; int boat; int boats = 0; char tmp[w+10]; memset(tmp, 0, w+10); for (i=0; i<h; i++){ scanf("%s", tmp); boat = findint(tmp); if (boat == -1) continue; boats++; (void*) strcpy(raw[boat], tmp); } //boats are in numeric order //for (i=0; i<h; i++) printf("%s\n", raw[i]); int dists[h]; memset(dists, 0, h); for (i=1; i <= boats; i++){ dists[i] = get_dist(raw[i]); //printf("%d\n", dists[i]); } //we have distances from the start for each boat int row; int rank = 1; int max; int rankings[boats]; memset(rankings, 0, boats); for(row=0; row<boats; row++){ max = get_max(dists); for (boat=1; boat<=boats; boat++){ if (dists[boat] == max){ rankings[boat] = rank; dists[boat] = -1; } } rank++; } for (i=1; i<h; i++) printf("%d\n", rankings[i]); return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
10 15
S..........222F S.....111.....F S...333.......F S...555.......F ... |
correct output |
---|
5
1 6 3 6 ... |
user output |
---|
4 1 5 2 5 ... |
Test 2
Verdict: ACCEPTED
input |
---|
10 10
S.....111F S....222.F S...333..F S..444...F ... |
correct output |
---|
1
2 3 4 5 ... |
user output |
---|
1 2 3 4 5 ... |
Test 3
Verdict: ACCEPTED
input |
---|
10 10
S...111..F S....222.F S.....333F S444.....F ... |
correct output |
---|
3
2 1 6 5 ... |
user output |
---|
3 2 1 6 5 ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 20
S..................F S...111............F S......222.........F S.........333......F ... |
correct output |
---|
9
7 5 3 1 ... |
user output |
---|
8 6 4 2 1 ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
20 20
S999...............F S..................F S..................F S..................F ... |
correct output |
---|
5
3 7 6 4 ... |
user output |
---|
5 3 7 6 4 ... |
Test 6
Verdict: WRONG ANSWER
input |
---|
30 30
S............................F... |
correct output |
---|
1
6 5 4 3 ... |
user output |
---|
1 5 4 3 2 ... |
Test 7
Verdict: WRONG ANSWER
input |
---|
30 30
S111.........................F... |
correct output |
---|
1
1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... |
Test 8
Verdict: WRONG ANSWER
input |
---|
30 30
S111.........................F... |
correct output |
---|
7
6 5 3 2 ... |
user output |
---|
7 6 5 3 2 ... |
Test 9
Verdict: WRONG ANSWER
input |
---|
30 30
S............................F... |
correct output |
---|
1
1 1 1 3 ... |
user output |
---|
1 1 1 1 3 ... |
Test 10
Verdict: WRONG ANSWER
input |
---|
30 30
S............................F... |
correct output |
---|
5
3 3 3 1 ... |
user output |
---|
5 3 3 3 1 ... |
Test 11
Verdict: WRONG ANSWER
input |
---|
30 30
S............................F... |
correct output |
---|
6
5 3 5 4 ... |
user output |
---|
5 4 2 4 3 ... |
Test 12
Verdict: WRONG ANSWER
input |
---|
30 30
S............................F... |
correct output |
---|
5
4 3 1 2 ... |
user output |
---|
5 4 3 1 2 ... |