Task: | Tenkici |
Sender: | henrikaalto |
Submission time: | 2019-07-27 20:41:26 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | details |
#2 | WRONG ANSWER | 0.01 s | details |
#3 | WRONG ANSWER | 0.01 s | details |
#4 | WRONG ANSWER | 0.01 s | details |
#5 | WRONG ANSWER | 0.01 s | details |
#6 | WRONG ANSWER | 0.01 s | details |
#7 | WRONG ANSWER | 0.01 s | details |
#8 | WRONG ANSWER | 0.01 s | details |
#9 | WRONG ANSWER | 0.01 s | details |
#10 | WRONG ANSWER | 0.01 s | details |
#11 | WRONG ANSWER | 0.01 s | details |
#12 | WRONG ANSWER | 0.01 s | details |
#13 | WRONG ANSWER | 0.02 s | details |
#14 | WRONG ANSWER | 0.01 s | details |
Code
#include <bits/stdc++.h> using namespace std; struct pos { int x, y; }; #define all(x) x.begin(), x.end() #define F first #define S second #define N 501 pos orig[N], fin[N]; pair<int,int> ycoords[N]; pair<int,int> xcoords[N]; int vapaa[N][N]; vector<pair<char, int>> moves; int n; int main() { cin >> n; for (int i = 1; i <= n; ++i) { fill(vapaa[i], vapaa[i] + N, 1); } for (int i = 1; i <= n; ++i) { cin >> orig[i].y >> orig[i].x; ycoords[i] = {orig[i].y, i}; xcoords[i] = {orig[i].x, i}; vapaa[orig[i].y][orig[i].x] = 0; } sort(ycoords + 1, ycoords + 1 + n); for (int i = 1; i <= n; ++i) { fin[ycoords[i].S].y = i; } for (int it = 1; it <= n; ++it) { for (int i = 1; i <= n; ++i) { while (orig[i].y < fin[i].y && vapaa[orig[i].y + 1][orig[i].x]) { moves.emplace_back('D', i); vapaa[orig[i].y][orig[i].x] = 1; orig[i].y++; vapaa[orig[i].y][orig[i].x] = 0; } while (orig[i].y > fin[i].y && vapaa[orig[i].y - 1][orig[i].x]) { moves.emplace_back('U', i); vapaa[orig[i].y][orig[i].x] = 1; orig[i].y--; vapaa[orig[i].y][orig[i].x] = 0; } } } sort(xcoords + 1, xcoords + 1 + n); for (int i = 1; i <= n; ++i) { fin[xcoords[i].S].x = i; } for (int i = 1; i <= n; ++i) { while (orig[i].x < fin[i].x) { moves.emplace_back('R', i); orig[i].x++; } while (orig[i].x > fin[i].x) { moves.emplace_back('L', i); orig[i].x--; } } cout << moves.size() << "\n"; for (auto [x, y] : moves) { cout << x << " " << y << "\n"; } }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
3
2 1 3 1 2 2 |
correct output |
---|
3
1 U 2 R 3 R |
user output |
---|
3 U 1 R 2 R 3 |
Test 2
Verdict: WRONG ANSWER
input |
---|
4
3 2 3 1 4 1 4 2 |
correct output |
---|
8
2 U 2 U 3 U 1 U ... |
user output |
---|
8 U 1 U 1 U 2 U 3 ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
5
5 4 4 2 4 4 2 2 ... |
correct output |
---|
6
5 U 5 U 4 U 2 U ... |
user output |
---|
6 U 2 U 3 U 4 U 2 ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
6
5 1 5 6 1 4 6 6 ... |
correct output |
---|
7
1 U 1 U 6 U 3 D ... |
user output |
---|
7 U 1 U 1 U 2 U 4 ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
7
5 3 4 4 5 5 3 5 ... |
correct output |
---|
8
6 D 5 U 3 D 7 U ... |
user output |
---|
8 D 3 U 4 D 6 U 7 ... |
Test 6
Verdict: WRONG ANSWER
input |
---|
8
8 7 2 2 8 8 2 1 ... |
correct output |
---|
16
4 D 2 D 2 D 5 D ... |
user output |
---|
16 D 2 D 4 D 4 U 6 ... |
Test 7
Verdict: WRONG ANSWER
input |
---|
9
1 2 2 2 8 8 9 8 ... |
correct output |
---|
24
8 D 8 D 2 D 2 D ... |
user output |
---|
24 D 2 D 2 U 3 U 3 ... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
10
4 2 5 3 7 1 3 2 ... |
correct output |
---|
36
4 U 4 U 1 U 1 U ... |
user output |
---|
36 U 2 U 2 U 4 U 4 ... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
50
1 47 12 29 35 12 6 47 ... |
correct output |
---|
544
34 D 34 D 34 D 34 D ... |
user output |
---|
544 D 2 D 2 D 2 D 2 ... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
100
53 50 31 76 46 54 94 37 ... |
correct output |
---|
1913
40 U 40 U 40 U 40 U ... |
user output |
---|
1913 U 2 U 2 U 2 U 2 ... Truncated |
Test 11
Verdict: WRONG ANSWER
input |
---|
250
196 74 148 245 203 19 113 198 ... |
correct output |
---|
2370
185 D 185 D 185 D 185 D ... |
user output |
---|
2370 U 1 U 1 U 1 U 1 ... Truncated |
Test 12
Verdict: WRONG ANSWER
input |
---|
350
185 170 222 294 183 181 159 171 ... |
correct output |
---|
25660
235 U 235 U 235 U 235 U ... |
user output |
---|
25660 D 1 D 1 D 1 D 1 ... Truncated |
Test 13
Verdict: WRONG ANSWER
input |
---|
465
160 163 177 231 220 111 430 330 ... |
correct output |
---|
48963
400 U 400 U 400 U 400 U ... |
user output |
---|
48963 U 1 D 2 D 2 D 2 ... Truncated |
Test 14
Verdict: WRONG ANSWER
input |
---|
500
428 393 30 377 76 52 21 218 ... |
correct output |
---|
10301
195 D 195 D 195 D 195 D ... |
user output |
---|
10301 U 1 U 1 U 1 U 1 ... Truncated |