CSES - COCI 2006/2007 #3 - Results
Submission details
Task:Tenkici
Sender:untokarila
Submission time:2019-07-28 20:54:04 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#20.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.01 sdetails
#7ACCEPTED0.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails

Code

#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define F first
#define S second

using namespace std;

int n, fix[501], fiy[501];
pair<int, int> x[501], y[501];

vector<pair<int, char> > ans;

int main(){

    cin >> n;

    for(int i=1; i<=n; i++){
        int a, b;
        cin >> a >> b;
        x[i] = {b, i};
        y[i] = {a, i};
    }

    sort(x+1, x+n+1);
    sort(y+1, y+n+1);

    for(int i=1; i<=n; i++){
        fix[x[i].S] = i;
        fiy[y[i].S] = i;
    }
    int s = 0;
    for(int i=(n+1)/2; i<=n && i>=1; i+=s){
        int m = fix[x[i].S]<x[i].F ? -1 : 1;
        char c  = fix[x[i].S]<x[i].F ? 'L' : 'R';
        while(fix[x[i].S] != x[i].F){
            ans.push_back({x[i].S, c});
            x[i].F += m;
        }
        if(s<=0) s--;
        else s++;
        s = -s;
    }

    for(int i=1; i<=n; i++){
        int m = fiy[y[i].S]<y[i].F ? -1 : 1;
        char c  = fiy[y[i].S]<y[i].F ? 'U' : 'D';
        while(fiy[y[i].S] != y[i].F){
            ans.push_back({y[i].S, c});
            y[i].F += m;
        }
    }

    cout << ans.size() << '\n';
    for(auto i : ans) cout << i.F << ' ' << i.S << '\n';

    return 0;
}
/*/
8
8 7
2 2
8 8
2 1
1 2
7 8
1 1
7 7
/*/

Test details

Test 1

Verdict: ACCEPTED

input
3
2 1
3 1
2 2

correct output
3
1 U
2 R
3 R

user output
3
2 R
3 R
1 U

Test 2

Verdict:

input
4
3 2
3 1
4 1
4 2

correct output
8
2 U
2 U
3 U
1 U
...

user output
8
3 R
1 R
4 R
4 R
...

Test 3

Verdict: ACCEPTED

input
5
5 4
4 2
4 4
2 2
...

correct output
6
5 U
5 U
4 U
2 U
...

user output
6
4 R
3 R
4 U
2 U
...

Test 4

Verdict: ACCEPTED

input
6
5 1
5 6
1 4
6 6
...

correct output
7
1 U
1 U
6 U
3 D
...

user output
7
6 R
2 L
5 D
1 U
...

Test 5

Verdict: ACCEPTED

input
7
5 3
4 4
5 5
3 5
...

correct output
8
6 D
5 U
3 D
7 U
...

user output
8
4 R
1 L
7 R
6 L
...

Test 6

Verdict: ACCEPTED

input
8
8 7
2 2
8 8
2 1
...

correct output
16
4 D
2 D
2 D
5 D
...

user output
16
5 R
5 R
1 L
1 L
...

Test 7

Verdict: ACCEPTED

input
9
1 2
2 2
8 8
9 8
...

correct output
24
8 D
8 D
2 D
2 D
...

user output
24
3 L
3 L
3 L
4 L
...
Truncated

Test 8

Verdict:

input
10
4 2
5 3
7 1
3 2
...

correct output
36
4 U
4 U
1 U
1 U
...

user output
36
8 R
8 R
8 R
2 R
...
Truncated

Test 9

Verdict:

input
50
1 47
12 29
35 12
6 47
...

correct output
544
34 D
34 D
34 D
34 D
...

user output
544
45 L
16 L
17 R
17 R
...
Truncated

Test 10

Verdict:

input
100
53 50
31 76
46 54
94 37
...

correct output
1913
40 U
40 U
40 U
40 U
...

user output
1913
13 L
61 L
56 R
55 L
...
Truncated

Test 11

Verdict:

input
250
196 74
148 245
203 19
113 198
...

correct output
2370
185 D
185 D
185 D
185 D
...

user output
2370
199 L
199 L
177 L
177 L
...
Truncated

Test 12

Verdict:

input
350
185 170
222 294
183 181
159 171
...

correct output
25660
235 U
235 U
235 U
235 U
...

user output
25660
290 L
35 L
247 L
247 L
...
Truncated

Test 13

Verdict:

input
465
160 163
177 231
220 111
430 330
...

correct output
48963
400 U
400 U
400 U
400 U
...

user output
48963
250 R
250 R
250 R
250 R
...
Truncated

Test 14

Verdict:

input
500
428 393
30 377
76 52
21 218
...

correct output
10301
195 D
195 D
195 D
195 D
...

user output
10301
468 L
64 L
84 L
71 L
...
Truncated