CSES - Siperia opettaa 3.0 - Results
Submission details
Task:Delete Files
Sender:zxc
Submission time:2016-07-29 17:49:56 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.06 sdetails
#20.06 sdetails
#30.05 sdetails
#40.05 sdetails
#50.06 sdetails
#60.06 sdetails
#70.06 sdetails
#80.07 sdetails
#90.07 sdetails
#100.06 sdetails
#110.06 sdetails
#120.06 sdetails
#130.06 sdetails
#140.06 sdetails
#150.06 sdetails
#160.06 sdetails
#170.06 sdetails
#180.07 sdetails
#190.06 sdetails
#200.06 sdetails
#210.07 sdetails
#220.06 sdetails
#230.06 sdetails
#240.06 sdetails
#250.07 sdetails
#260.06 sdetails
#270.05 sdetails
#280.06 sdetails
#290.05 sdetails
#300.06 sdetails
#310.07 sdetails
#320.06 sdetails
#330.06 sdetails
#340.05 sdetails
#350.07 sdetails
#360.06 sdetails
#370.07 sdetails
#380.06 sdetails
#390.06 sdetails
#400.06 sdetails
#410.06 sdetails
#420.06 sdetails
#430.06 sdetails
#440.06 sdetails
#450.06 sdetails
#460.06 sdetails
#470.06 sdetails
#480.07 sdetails
#490.06 sdetails
#500.05 sdetails
#510.02 sdetails
#520.06 sdetails
#530.06 sdetails
#540.07 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:41:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0; i < cmp.size(); ++i) {
                                ^

Code

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll MN = 3e5+100;
ll start[MN];
ll arr[MN];
ll arr2[MN][4];
pair<ll, ll> t[MN];
pair<ll, ll> pck[MN];
set<pair<ll, ll> > sv[MN];
set<pair<ll, ll> > sh[MN];
char dir[MN];
ll mov[MN][2];
ll ans[MN][2];

map<pair<ll, ll>, int> qwe;
int main() {
    ll n,T;
    cin>>n>>T;
    vector<ll> cmp;
    for(ll i = 0; i < n; ++i) {
	cin>>t[i].F>>t[i].S>>dir[i];
	if(dir[i] == 'U') mov[i][1] = 1;
	if(dir[i] == 'D') mov[i][1] = -1;
	if(dir[i] == 'L') mov[i][0] = -1;
	if(dir[i] == 'R') mov[i][0] = 1;
	cmp.push_back(t[i].F);
	cmp.push_back(t[i].S);
	qwe[{t[i].F, t[i].S}] = i;
	ans[i][0] = t[i].F;
	ans[i][1] = t[i].S;
	start[i] = -1;
	arr[i] = -1;
	for(int j = 0; j < 4; ++j) arr2[i][j] = 2e18;
    }
    sort(cmp.begin(), cmp.end());
    cmp.erase(unique(cmp.begin(), cmp.end()), cmp.end());
    map<ll, ll> mp;
    for(ll i = 0; i < cmp.size(); ++i) {
	mp[cmp[i]] = i;
    }
    for(ll i = 0; i < n; ++i) {
	sv[mp[t[i].F]].insert({mp[t[i].S], i});
	sh[mp[t[i].S]].insert({mp[t[i].F], i});
    }
    set<pair<ll, ll> > qq;
    qq.insert({0, 0});
    start[0] = 0;
    ans[0][0] = t[0].F;
    ans[0][1] = t[0].S;
    ans[0][0] += T * mov[0][0];
    ans[0][1] += T * mov[0][1];
    ll cx = mp[t[0].F];
    ll cy = mp[t[0].S];
    sv[cx].erase({t[0].S, 0});
    sh[cy].erase({t[0].F, 0});
    while(qq.size()) {
	auto p = *qq.begin();
	qq.erase(*qq.begin());
	ll x = t[p.S].F + mov[p.S][0] * (p.F-start[p.S]);
	ll y = t[p.S].S + mov[p.S][1] * (p.F-start[p.S]);
	int c = qwe[{x, y}];
	if(p.F > T) break;
	if(start[c] == -1) {
	    ans[c][0] = t[c].F;
	    ans[c][1] = t[c].S;
	    ans[c][0] += (T-p.F)*mov[c][0];
	    ans[c][1] += (T-p.F)*mov[c][1];

	    start[c] = p.F;
	    qq.insert({p.F, c});
	    ll cx = mp[t[c].F];
	    ll cy = mp[t[c].S];
	    sv[cx].erase({t[c].S, c});
	    sh[cy].erase({t[c].F, c});
	}
	ll px = mp[x];
	ll py = mp[y];
	if(dir[p.S] == 'U') {
	    auto z = sv[px].lower_bound({y, 0});
	    if(z == sv[px].end()) continue;
	    auto z2 = *z;
	    ll time = t[z2.S].S-y + p.F;
	    //cout<<"LOL "<<time<<'\n';
	    if(arr2[z2.S][2] <= time) {
		continue;
	    }
	    arr2[z2.S][2] = time;
	    qq.insert({time, p.S});
	}
	if(dir[p.S] == 'D') {
	    auto z = sv[px].lower_bound({y, 0});
	    if(z == sv[px].begin()) continue;
	    --z;
	    auto z2 = *z;
	    ll time = y-t[z2.S].S + p.F;
	    if(arr2[z2.S][0] <= time) {
		continue;
	    }
	    arr2[z2.S][0] = time;
	    qq.insert({time, p.S});
	}
	if(dir[p.S] == 'R') {
	    auto z = sh[py].lower_bound({x, 0});
	    if(z == sh[py].end()) continue;
	    auto z2 = *z;
	    ll time = t[z2.S].F-x + p.F;
	    if(arr2[z2.S][3] <= time) {
		continue;
	    }
	    arr2[z2.S][3] = time;
	    qq.insert({time, p.S});
	}
	if(dir[p.S] == 'L') {
	    auto z = sh[py].lower_bound({x, 0});
	    if(z == sh[py].begin()) continue;
	    --z;
	    auto z2 = *z;
	    ll time = x - t[z2.S].F + p.F;
	    if(arr2[z2.S][1] <= time) {
		continue;
	    }
	    arr2[z2.S][1] = time;
	    qq.insert({time, p.S});
	}
    }
    for(int i = 0; i < n; ++i) {
	cout<<ans[i][0]<<' '<<ans[i][1]<<'\n';
    }
}

Test details

Test 1

Verdict:

input
576
y 514
n 505
y 613
y 641
...

correct output
117

user output
0 0
0 0
0 0
0 0
0 0
...

Test 2

Verdict:

input
789
y 174
y 184
y 916
n 489
...

correct output
162

user output
0 0
0 0
0 0
0 0
0 0
...

Test 3

Verdict:

input
153
y 749
n 255
y 728
n 725
...

correct output
37

user output
0 0
0 0
0 0
0 0
0 0
...

Test 4

Verdict:

input
554
y 714
n 389
n 123
y 954
...

correct output
122

user output
0 0
0 0
0 0
0 0
0 0
...

Test 5

Verdict:

input
572
n 81
y 160
y 262
y 616
...

correct output
122

user output
0 0
0 0
0 0
0 0
0 0
...

Test 6

Verdict:

input
426
n 977
y 656
n 100
n 28
...

correct output
83

user output
0 0
0 0
0 0
0 0
0 0
...

Test 7

Verdict:

input
3
y 7
y 6
n 5

correct output
1

user output
0 0
0 0
0 0

Test 8

Verdict:

input
166
n 955
y 364
y 372
y 621
...

correct output
41

user output
0 0
0 0
0 0
0 0
0 0
...

Test 9

Verdict:

input
352
n 342
y 828
n 925
y 652
...

correct output
69

user output
0 0
0 0
0 0
0 0
0 0
...

Test 10

Verdict:

input
304
y 962
y 712
n 754
n 359
...

correct output
69

user output
0 0
0 0
0 0
0 0
0 0
...

Test 11

Verdict:

input
836
n 890
y 790
y 406
n 127
...

correct output
171

user output
0 0
0 0
0 0
0 0
0 0
...

Test 12

Verdict:

input
1000
y 198
n 603
n 511
y 207
...

correct output
209

user output
0 0
0 0
0 0
0 0
0 0
...

Test 13

Verdict:

input
1000
n 548
n 362
y 298
n 576
...

correct output
207

user output
0 0
0 0
0 0
0 0
0 0
...

Test 14

Verdict:

input
1000
y 891
n 240
n 61
y 226
...

correct output
205

user output
0 0
0 0
0 0
0 0
0 0
...

Test 15

Verdict:

input
1000
y 760
y 165
y 592
y 73
...

correct output
228

user output
0 0
0 0
0 0
0 0
0 0
...

Test 16

Verdict:

input
1000
y 220
n 377
n 312
n 750
...

correct output
217

user output
0 0
0 0
0 0
0 0
0 0
...

Test 17

Verdict:

input
1000
n 390
n 932
y 505
n 687
...

correct output
208

user output
0 0
0 0
0 0
0 0
0 0
...

Test 18

Verdict:

input
3
y 7
n 6
y 5

correct output
2

user output
0 0
0 0
0 0

Test 19

Verdict:

input
1000
y 140
y 896
y 599
n 308
...

correct output
214

user output
0 0
0 0
0 0
0 0
0 0
...

Test 20

Verdict:

input
1000
y 107
y 681
y 755
y 51
...

correct output
215

user output
0 0
0 0
0 0
0 0
0 0
...

Test 21

Verdict:

input
1000
y 537
y 404
y 445
n 934
...

correct output
211

user output
0 0
0 0
0 0
0 0
0 0
...

Test 22

Verdict:

input
1000
n 597
y 510
n 464
n 76
...

correct output
196

user output
0 0
0 0
0 0
0 0
0 0
...

Test 23

Verdict:

input
819
n 802
y 230
n 554
y 774
...

correct output
263

user output
0 0
0 0
0 0
0 0
0 0
...

Test 24

Verdict:

input
307
n 667
y 198
n 985
y 531
...

correct output
95

user output
0 0
0 0
0 0
0 0
0 0
...

Test 25

Verdict:

input
131
n 149
y 274
n 843
y 526
...

correct output
39

user output
0 0
0 0
0 0
0 0
0 0
...

Test 26

Verdict:

input
807
n 229
y 726
n 63
y 923
...

correct output
256

user output
0 0
0 0
0 0
0 0
0 0
...

Test 27

Verdict:

input
38
n 840
y 592
n 479
y 612
...

correct output
13

user output
0 0
0 0
0 0
0 0
0 0
...

Test 28

Verdict:

input
699
n 945
y 34
n 441
y 601
...

correct output
237

user output
0 0
0 0
0 0
0 0
0 0
...

Test 29

Verdict:

input
6
y 4
n 5
y 4
y 6
...

correct output
2

user output
0 0
0 0
0 0
0 0
0 0
...

Test 30

Verdict:

input
957
n 513
y 323
n 105
y 961
...

correct output
333

user output
0 0
0 0
0 0
0 0
0 0
...

Test 31

Verdict:

input
156
n 269
y 430
n 375
y 204
...

correct output
52

user output
0 0
0 0
0 0
0 0
0 0
...

Test 32

Verdict:

input
760
n 146
y 180
n 861
y 743
...

correct output
249

user output
0 0
0 0
0 0
0 0
0 0
...

Test 33

Verdict:

input
323
n 662
y 7
n 128
y 836
...

correct output
106

user output
0 0
0 0
0 0
0 0
0 0
...

Test 34

Verdict:

input
373
n 100
n 995
n 435
n 946
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 35

Verdict:

input
220
y 38
y 846
y 547
y 639
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 36

Verdict:

input
981
n 952
n 180
n 735
n 406
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 37

Verdict:

input
758
y 474
y 790
y 199
y 367
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 38

Verdict:

input
262
n 837
n 221
n 836
n 371
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 39

Verdict:

input
969
y 122
y 546
y 211
y 719
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 40

Verdict:

input
773
n 368
n 640
n 356
n 39
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 41

Verdict:

input
803
y 79
y 111
y 459
y 755
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 42

Verdict:

input
190
n 192
n 453
n 996
n 894
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 43

Verdict:

input
193
y 86
y 673
y 18
y 271
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 44

Verdict:

input
1000
n 1000
n 1000
n 1000
y 1000
...

correct output
250

user output
0 0
0 0
0 0
0 0
0 0
...

Test 45

Verdict:

input
1000
n 1000
y 1000
y 1000
y 1000
...

correct output
245

user output
0 0
0 0
0 0
0 0
0 0
...

Test 46

Verdict:

input
1000
y 1000
n 1000
n 1000
y 1000
...

correct output
242

user output
0 0
0 0
0 0
0 0
0 0
...

Test 47

Verdict:

input
1000
n 1000
n 1000
n 1000
y 1000
...

correct output
237

user output
0 0
0 0
0 0
0 0
0 0
...

Test 48

Verdict:

input
1000
y 1000
y 1000
n 1000
y 1000
...

correct output
243

user output
0 0
0 0
0 0
0 0
0 0
...

Test 49

Verdict:

input
1000
n 1000
n 1000
n 1000
n 1000
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 50

Verdict:

input
1000
y 1000
y 1000
y 1000
y 1000
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 51

Verdict:

input
1000
n 1000
n 1000
n 1000
n 1000
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 52

Verdict:

input
1000
y 1000
y 1000
y 1000
y 1000
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0
...

Test 53

Verdict:

input
1000
n 1000
n 1000
n 1000
n 1000
...

correct output
0

user output
0 0
0 0
0 0
0 0
0 0
...

Test 54

Verdict:

input
5
y 10
y 5
n 4
y 8
...

correct output
1

user output
0 0
0 0
0 0
0 0
0 0