Task: | Npuzzle |
Sender: | henrikaalto |
Submission time: | 2019-07-24 14:08:48 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | ACCEPTED | 0.01 s | details |
#8 | ACCEPTED | 0.01 s | details |
#9 | ACCEPTED | 0.01 s | details |
#10 | ACCEPTED | 0.01 s | details |
Code
#include <bits/stdc++.h> using namespace std; int main() { const int N = 4; vector<string> v(N); for (int i = 0; i < N; ++i) { cin >> v[i]; } pair<int,int> lol = {0, 0}; vector<pair<int,int>> r(256); r['A'] = lol; for (int i = 'B'; i <= 'O'; ++i) { lol.second++; if (lol.second == N) { lol.second = 0; lol.first++; } r[i] = lol; } int res = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (v[i][j] == '.') continue; res += abs(i - r[v[i][j]].first) + abs(j - r[v[i][j]].second); } } cout << res << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCD
EFGH IJKL MNO. |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
ABCD
EFGH IJK. MNOL |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
ABCD
EF.H IJGL MNKO |
correct output |
---|
3 |
user output |
---|
3 |
Test 4
Verdict: ACCEPTED
input |
---|
ABCD
IEGH MFJL N.KO |
correct output |
---|
8 |
user output |
---|
8 |
Test 5
Verdict: ACCEPTED
input |
---|
.BHG
ADCE IFOK MJNL |
correct output |
---|
18 |
user output |
---|
18 |
Test 6
Verdict: ACCEPTED
input |
---|
ACD.
NFKI JOHM GELB |
correct output |
---|
33 |
user output |
---|
33 |
Test 7
Verdict: ACCEPTED
input |
---|
IKBJ
DMEG LFO. CHAN |
correct output |
---|
41 |
user output |
---|
41 |
Test 8
Verdict: ACCEPTED
input |
---|
ABCM
EJFN IKGO DHL. |
correct output |
---|
28 |
user output |
---|
28 |
Test 9
Verdict: ACCEPTED
input |
---|
.ONM
LKJI HGFE DCBA |
correct output |
---|
58 |
user output |
---|
58 |
Test 10
Verdict: ACCEPTED
input |
---|
MNO.
IJKL EFGH ABCD |
correct output |
---|
29 |
user output |
---|
29 |