QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55074#1774. Customs ControlsMIT01#AC ✓194ms15400kbC++2.1kb2022-10-12 08:50:322022-10-12 08:50:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 08:50:34]
  • 评测
  • 测评结果:AC
  • 用时:194ms
  • 内存:15400kb
  • [2022-10-12 08:50:32]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define mod 998244353
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
using namespace std;
const int maxn = 100005;

int n, m, k;
int tp[maxn];
ll dis[maxn];
int t[maxn];
vi eg[maxn];
priority_queue<pair<ll, int > > q;
int main() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        cin >> t[i];
    int flag = 0;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        if (min(u, v) == 1 && max(u, v) == n) flag = 1;
        eg[u].pb(v);
        eg[v].pb(u);
    }
    const ll inf = 1e18;
    for (int i = 0; i <= n; i++)
        dis[i] = inf;
    dis[1] = 0;
    q.push(mp(0, 1));
    while (!q.empty()) {
        auto [d, id] = q.top(); q.pop();
        if (d != -dis[id]) continue;
        for (auto v : eg[id]) 
            if (chkmin(dis[v], dis[id] + t[v])) 
                q.push(mp(-dis[v], v));
    }
    if (flag) {
        if (n == 2 && k == 1) {
            cout << "impossible" << endl;
            return 0;
        }
        else {
            int rev = 0;
            if (k < 2) rev = 1, k = n - k;
            tp[1] = tp[n] = 0; k -= 2;
            for (int j = 2; j <= k + 1; j++) tp[j] = 0;
            for (int j = k + 2; j < n; j++) tp[j] = 1;
            if (rev) 
                for (int j = 1; j <= n; j++) tp[j] ^= 1;
        }
    }
    else {
        vector<pair<ll, int> > cr;
        for (int i = 1; i <= n; i++)
            cr.pb(mp(dis[i], i));
        sort(cr.begin(), cr.end());
        for (int j = 0; j < k; j++)
            tp[cr[j].se] = 0;
        for (int j = k; j < n; j++)
            tp[cr[j].se] = 1;
    }
    for (int i = 1; i <= n; i++)
        cout << (tp[i] ? 'S' : 'N'); cout << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 5884kb

input:

5 10 2
1 1 1 1 1
3 4
5 4
3 1
4 1
3 5
2 1
2 4
2 5
1 5
2 3

output:

NSSSN

result:

ok accepted

Test #2:

score: 0
Accepted
time: 2ms
memory: 5984kb

input:

10 9 5
1 1 1 1 1 1 1 1 1 1
9 5
7 1
8 1
10 1
5 3
6 1
2 1
3 2
4 1

output:

NNNNSSSSSN

result:

ok accepted

Test #3:

score: 0
Accepted
time: 3ms
memory: 6052kb

input:

2 1 2
6124 7094
2 1

output:

NN

result:

ok accepted

Test #4:

score: 0
Accepted
time: 0ms
memory: 5840kb

input:

2 1 1
6901 1417
2 1

output:

impossible

result:

ok accepted

Test #5:

score: 0
Accepted
time: 0ms
memory: 5844kb

input:

50 67 25
5 10 5 4 3 3 8 7 10 4 6 6 9 8 5 1 5 9 3 2 3 8 9 9 2 8 7 8 9 8 3 3 10 7 5 5 7 1 6 9 4 6 9 10 4 10 9 10 9 5
45 35
27 17
11 14
34 1
49 37
4 2
9 3
42 9
13 25
40 32
38 17
28 1
26 14
13 19
41 40
38 40
12 6
14 7
47 25
30 21
32 22
7 6
16 12
15 9
20 16
29 3
21 8
19 9
18 23
43 5
5 3
11 35
10 7
36 16
...

output:

NNNNNNNNNNNNSSSNSSSNSSSSNSSNNSNNSNNNNSNSSSSNSSSSSS

result:

ok accepted

Test #6:

score: 0
Accepted
time: 4ms
memory: 5988kb

input:

100 99 50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
34 11
79 3
36 30
59 24
83 14
88 23
19 9
44 19
91 11
40 14
58 37
99 30
45 12
81 66
38 35
73...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNSSNSSNSNNSSNSSNNSSNSNNSNNSNSSSSSNSNSSSSSSSSSSSSNNSNSNNSSSNSSSSSSNNSSSSSNSSN

result:

ok accepted

Test #7:

score: 0
Accepted
time: 1ms
memory: 5844kb

input:

200 400 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

NNNNNNNNNNNNNNNNNNNNNSNNNSNNNNNSNSNNNSNSSSNSNSSSSSSSSSNNSNNSNNNSSSSNNNNSNNSSSNNSSNSSSSNNNNSNSNSSSNNSNSSNSNNSNSSSNSSSNSSSSSNNNSNNNNSSSSNSSSSNNNNSNSNSSSNNNNSSSSNNSSSSNNSSSNSNSNSNSSNNNNSSSNSNSSNSSSSSSSSS

result:

ok accepted

Test #8:

score: 0
Accepted
time: 4ms
memory: 5892kb

input:

400 2000 50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

NNNNNNNNNNSNNNNSNNSSNNNSSNSSNSSSSSSSSSSNSSSNNSSNSNNNSSNNNNSSSSSNNNSSNNNNNNSSSSSSSSSSNSSSSSNSSSSNSSSSSNSSSSSSSSSSSSSNSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSNSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS...

result:

ok accepted

Test #9:

score: 0
Accepted
time: 4ms
memory: 6152kb

input:

800 1600 400
6778 2494 1425 4552 1937 7148 830 9892 8936 4711 2727 7103 8171 3131 3086 8687 7433 3238 6572 1018 9461 9638 1484 666 3143 9266 5392 8490 5948 6927 9595 2267 7386 411 8292 5330 968 8697 1138 8303 5827 8830 8821 7204 2407 4636 985 7995 431 4492 6978 4675 2773 3208 6624 1770 6094 1576 590...

output:

NNNNNNNNNSNNSNNNNNNNNSNNNSNSNNSNNNSNNNNSNSSSNNNSNNSNNNNNNNNSNNNNNNSNSNNNNNNNNSNNSNNNNSSSNSNNSSNNNSSNNSNNSNNSSNSNSSNNSNSNSSNNNSNNSNSNSSNNNSNSSSNNSNNNSNNSNNSSSNSNSSSNNSSNNSNNNNNSNSNNSSNNSSSNSSNSSSSSNNNNSNNSSSNSNSSNSSSNNNNNSNSNSSSNSNNNSNNNNSNSNSNSSSSNSSSNSNSSNSNNNNSNNNNSSSSNSNSNSSNNSNNSSNSSNNSSNSNNNSNN...

result:

ok accepted

Test #10:

score: 0
Accepted
time: 1ms
memory: 6212kb

input:

1601 1637 800
11 20 4 18 4 15 7 15 4 4 3 8 16 18 9 7 9 16 9 4 16 3 11 14 19 2 19 20 15 5 2 8 6 10 8 14 20 8 10 6 9 13 16 5 14 19 18 13 7 17 19 18 9 15 3 2 12 2 2 12 3 3 16 5 4 16 8 17 10 3 14 18 15 13 3 10 14 5 4 18 18 10 9 14 14 7 5 4 12 13 7 13 4 8 13 20 14 6 3 6 18 1 5 20 7 11 1 1 11 5 16 2 11 7 ...

output:

NNNNNNNNNNNNNSNNNNNNNNSSNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNSNNSNSSNNNNSNNNNSNNNNNNNNNNNNNNNSNNNNSNSNNSSSNNSNNNNNNNNNNNSNNNNSSNNNSNNNNNNSSNSSNNSSNNNNSNNNSNNNNNNNSNSNNNNNNSNNNSNNSSNNNNNSNNNSSNNNNNNNNSSNSNNSNSNSNSSNNNSSNSNNNSSNNNNSSSNSNNNNSNNSSNNNSSNNNNSNSNNSSNNNNSSNNNNSNSNNSNNNSSSNN...

result:

ok accepted

Test #11:

score: 0
Accepted
time: 4ms
memory: 6564kb

input:

10000 9999 500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNSSSNNNNSNNNNNSNNSNNNSSSNSSSSNNNSSNSSNSNSNNSSNNNSNNNSNNNNSSSSSNNSNNSNNSNNNSSNNSNSNNSSNSNSSSSNSNSNNNSNNSSSSNSNSSSSSSSSSSNSNSNSNNNSSNSSSNSSSSNSSSSSSSSSSSSSSNSSSSNSSSSSSSSSNNNSNSSSNSSSSSSNSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSNSSSSSSSSNSNNSSSSSNSNNNNNSNSSSSSNSSSSSSNNSNSSS...

result:

ok accepted

Test #12:

score: 0
Accepted
time: 3ms
memory: 6744kb

input:

10000 20000 5000
8295 3745 794 1318 1691 7504 9376 1326 507 2339 256 9868 9674 3268 6993 4296 3924 9424 3276 5493 3019 1786 832 6542 5285 2221 6770 1310 1695 3270 5800 1424 7943 8349 6731 1523 8935 4374 5 7139 808 5421 6233 7507 5372 4693 382 1098 1083 8487 1602 5114 9404 318 9440 4081 1355 38 6967 ...

output:

NNNNNNNNNNNSNNSNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNSNNSNNNNNNNNNNNNSNNNNNNNNNSSNNSNNNSSNNNNNNNNNNNSNNNNNSSSNNSNSSNNNNNNNNSSNNNNNSNNSSNNSNNNNNNNNNNSNNNNNNNSNNNSSSNSNSSNNNSSNNNNNNNNSNNNNNSNNNNNNNNNSNNNNSSNSNSNSNNNNNNSNNNNNNNNNNNSSSSNNSSNSNNNSSNNNNSNNNNNNSNNSSNSSSNNNNSSNSSNNNNNNNSNNNNNNSSNNSNSNN...

result:

ok accepted

Test #13:

score: 0
Accepted
time: 163ms
memory: 13684kb

input:

100000 200000 50000
6610 9169 2169 6552 433 1085 6451 9008 2102 5083 8156 6290 9891 531 7776 2219 6685 2750 6288 2201 2433 1734 4059 8849 7272 6446 279 6743 318 4626 1731 496 2821 7543 9915 143 8983 1939 4554 2999 8949 6805 7900 9442 4881 5738 3164 651 8646 7282 6329 2213 2211 6679 3677 2075 6931 79...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNSNNNNNSNNNNNNNNSNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNSNNNNNSNNNNNNNNNNNSNNNNSNNNNNNNNNNSNNSNSNNNNNSSNNNNNSNNNNSNNNNNNSNNNSNNNNNNNNNNNNNNNNNNNNSSNNNNNNNNNSNNNNNNNNSNNSNSSNNSSNNNNNSNNNNNNNSNNNNNNNNNNNNNNSNNNNNNNNSSSNNSNNNNNNNNNNNNNNNNNNSSNNNNNSNNNNNNNNNNSNNNNNN...

result:

ok accepted

Test #14:

score: 0
Accepted
time: 83ms
memory: 12368kb

input:

100000 100010 50000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #15:

score: 0
Accepted
time: 84ms
memory: 12340kb

input:

100000 100048 50000
10 4 9 3 4 5 8 10 6 2 10 7 1 2 2 9 9 2 7 6 10 3 2 2 8 5 10 5 6 5 3 1 7 6 5 3 5 9 1 3 1 7 10 8 8 5 4 4 8 10 6 10 10 6 4 10 2 6 8 9 2 5 6 10 3 7 9 8 7 4 9 9 2 2 5 7 9 9 7 4 7 1 8 8 5 7 8 3 9 6 3 6 6 6 3 8 1 1 10 8 6 9 7 3 10 10 4 4 10 1 7 2 1 7 10 2 9 5 7 7 1 10 4 6 4 1 6 1 1 2 6 7...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNSN...

result:

ok accepted

Test #16:

score: 0
Accepted
time: 161ms
memory: 13592kb

input:

100000 200000 1
3483 3913 2465 4127 2680 1151 6612 1498 6652 966 688 8449 312 9341 1289 2574 7250 2310 8421 5242 4799 7903 4517 8356 6465 5466 2562 2052 9897 8666 6149 9850 184 9535 9355 8845 7330 2183 1492 4985 2352 1362 1928 4940 5895 8893 2251 6792 4679 2146 2677 3667 4218 5797 8433 3462 8459 806...

output:

NSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS...

result:

ok accepted

Test #17:

score: 0
Accepted
time: 4ms
memory: 5904kb

input:

10 14 4
10000 10000 3921 6078 1 10000 10000 10000 10000 10000
10 6
1 2
1 8
10 8
3 5
1 3
5 4
1 6
10 2
10 4
10 7
10 9
1 7
1 9

output:

NNNSNSSSSS

result:

ok accepted

Test #18:

score: 0
Accepted
time: 4ms
memory: 5908kb

input:

10 15 5
10000 1 9399 10000 10000 600 10000 10000 10000 10000
10 5
1 8
10 3
1 10
10 9
6 2
10 7
1 7
1 6
1 5
1 4
10 8
10 4
2 3
1 9

output:

NNNNSSSSSN

result:

ok accepted

Test #19:

score: 0
Accepted
time: 1ms
memory: 5984kb

input:

100 168 50
10000 10000 10000 10000 10000 6586 1467 10000 6994 2298 10000 1776 10000 1 2243 3413 10000 10000 3006 10000 7548 2493 1 1 1 10000 7506 7757 6994 3413 10000 1 10000 1 4048 10000 1 2493 6587 2451 10000 3005 1 10000 7701 7701 1 2451 10000 10000 10000 8020 10000 4049 10000 1 7702 8019 10000 1...

output:

NNNNNNNNNNNNNNNNNNSSNSNNNSNSNSSNSNNSNSNSSSNSSSNSSSSNSNSNSNSNSSSNNSSSSSSNSSNSSSNSSSSSNNNNSSNNNNSSSNSS

result:

ok accepted

Test #20:

score: 0
Accepted
time: 16ms
memory: 6660kb

input:

10000 17794 4999
10000 7007 10000 10000 1 1 1 568 1223 10000 7048 2022 641 1 1 1552 4577 8702 1561 1002 1 10000 7410 9362 10000 2213 2399 6613 10000 3383 1533 10000 3170 10000 10000 9085 78 7457 1182 889 10000 1582 10000 266 1444 10000 10000 10000 3092 3223 4394 10000 6512 6427 10000 4924 153 1 1000...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #21:

score: 0
Accepted
time: 142ms
memory: 13456kb

input:

100000 170882 49999
10000 1 10000 1 2457 8300 2260 7495 1 10000 10000 551 1 4673 1 10000 10000 1 9392 1 3434 1 8007 1 4858 4213 1 10000 1 10000 6215 10000 4673 7163 1 6553 2524 10000 768 6719 2790 2725 2164 10000 1585 1 1 1 7436 10000 10000 9819 1 1 5952 10000 589 10000 7555 4215 4121 10000 1 10000 ...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #22:

score: 0
Accepted
time: 115ms
memory: 11784kb

input:

100000 170753 50000
10000 10000 1775 6788 10000 861 10000 3386 1 10000 4214 1106 10000 10000 10000 1 10000 5439 10000 10000 1 6290 10000 2832 10000 8674 10000 1114 7592 5419 7779 1 10000 1 3264 1 7455 10000 4944 10000 4238 10000 10000 10000 10000 8950 4663 9969 10000 10000 10000 10000 10000 400 2589...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #23:

score: 0
Accepted
time: 194ms
memory: 13404kb

input:

100000 175017 50000
10000 7353 6751 10000 3172 1 8731 6019 10000 10000 10000 3264 8517 6000 1323 5422 9073 6059 1388 8703 3814 4367 8158 10000 1 10000 9041 3841 7224 6884 10000 4347 10000 2602 10000 1364 3794 5352 6806 3273 7001 10000 8142 2450 3142 10000 10000 10000 1076 3829 1756 10000 9977 8646 8...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #24:

score: 0
Accepted
time: 1ms
memory: 5880kb

input:

3 3 2
1 1 1
1 2
1 3
3 2

output:

NSN

result:

ok accepted

Test #25:

score: 0
Accepted
time: 2ms
memory: 6056kb

input:

3 3 1
1 1 1
1 2
1 3
3 2

output:

SNS

result:

ok accepted

Test #26:

score: 0
Accepted
time: 5ms
memory: 5968kb

input:

10 13 5
6536 7635 84 7635 7635 66 51 7635 7635 9711
1 9
9 7
1 8
1 5
2 7
4 7
1 2
1 4
7 6
8 7
5 7
6 3
3 10

output:

NNSNNSSNSS

result:

ok accepted

Test #27:

score: 0
Accepted
time: 2ms
memory: 5992kb

input:

10 13 5
5773 5 7095 51 7095 7095 7095 7095 56 6419
10 7
6 9
10 5
3 4
8 4
4 2
10 6
10 8
10 3
2 1
5 4
7 4
9 1

output:

NNNNSSSSNS

result:

ok accepted

Test #28:

score: 0
Accepted
time: 3ms
memory: 6080kb

input:

1000 1498 500
3786 27 41 1690 8 96 13 72 1690 1690 1690 24 1690 71 1690 1690 1690 1690 45 60 1690 63 1690 59 1690 46 52 1690 84 1690 1690 1690 1690 1690 1690 77 1690 1690 1690 40 1690 11 1690 92 1690 1690 25 35 1690 1690 1690 7 62 26 1690 1690 86 35 1690 1690 21 1690 38 1690 3 58 77 1690 1690 19 169...

output:

NSSNSSSSNNNSNSNNNNSSNSNSNSSNSNNNNNNSNNNSNSNSNNSSNNNSSSNNSSNNSNSNSSSNNSNNSSNSSSSSSNNSNSSNNNNSSSNSNSNSSSSSNSSNSSSNNNNNSSSSNSSNSSSNNSNNNNSSSNNNSNNSNSNSNNNNSNSNSNSSSSNNSNSSNNNNSNSSNNNNNSSNSNSNNSSNNSSSNSSSSSNSNNNNSNNSSNNNSSSSNNSNNNNSNSSNSNNNSSNSSNNNSNNNSNSSSSSSSSNNSNNSSSSSSSNSNNNSSSSNNSSNSSSNSNNSSNNNNSNS...

result:

ok accepted

Test #29:

score: 0
Accepted
time: 165ms
memory: 13032kb

input:

100000 149998 50000
9823 27 54 45 91 8 95 79 80 44 48 1954 1954 1954 19 11 1 81 29 34 71 1954 1954 1954 47 1954 32 1954 1954 1954 1954 98 39 1954 1954 1954 1954 1954 1954 1954 81 13 52 28 1954 35 71 1954 94 93 1954 1954 23 91 1954 85 69 5 24 1954 52 38 1954 1954 28 84 1954 1954 14 1954 98 22 15 1954...

output:

NSSSSSSSSSSNNNSSSSSSSNNNSNSNNNNSSNNNNNNNSSSSNSSNSSNNSSNSSSSNSSNNSSNNSNSSSNNNNSNNNSNSSSNNNSSSSNSNNNSNNNNSSNNNSNNNSSNNSSNNNSNSNSSNSNSSSSNNNSSSNNSSSSSNSSNNSNSNSNSSSSNNNNNNSNNSNNNNSNNSNSNNNSNSNNNSSNSSNNSNNSNNSSSNNNNSNNSSSNNSNNSSNNNNSNNSSSNSNNSSNNSNSSNSNNSNSSSSNSNNSSSNNNSSNNNNSSSNNNSNNNSNNNSNNSNSNSNNSSSN...

result:

ok accepted

Test #30:

score: 0
Accepted
time: 130ms
memory: 13104kb

input:

100000 149998 50000
2255 33 83 39 2316 2316 2316 99 98 85 2316 2316 75 2316 62 2316 2316 10 2316 2316 74 2316 28 39 2316 66 47 80 41 68 24 30 2316 26 2316 2316 2316 2316 46 2316 83 2316 2316 2316 72 2316 60 71 2316 50 97 2316 22 12 2316 2 2316 2316 2316 2316 2316 44 2316 2316 2316 2316 2316 3 65 231...

output:

NNNNNSSNNNSSNSNSSNSSNSNNSNNNNNNNSNSSSSNSNSSSNSNNSNNSNNSNSSSSSNSSSSSNNSNSNNNSSNNSNNNNNSNNSNSSNNSSSSSNNNSNNSSNNNSNNSNSSNSNNNSSSSNSNSSNNNSNSSNSNNNSSNNNSSNNNNNNSSNNSSSNNNNNSNSNNSNNSNSNSNSSNSNNNSSNNSNSNNSNSNNNSSSNSSSSNNNSNNSNNSNNNSSSNSNNSNSNNNSNNSNSSNSSNNNSNSNNSNNSNSNSSSNNSSSSSNSSSNNSNNNNSNSNNSNNSNNNSSNS...

result:

ok accepted

Test #31:

score: 0
Accepted
time: 136ms
memory: 14640kb

input:

100000 169998 50000
460 7579 7579 7579 41 7579 91 7579 7579 7579 62 7579 41 28 7579 7579 7579 1 7579 7579 7579 7579 7579 7579 7579 14 7579 49 7579 90 9 7579 7579 7579 89 7579 7579 7579 7579 7579 7579 7579 58 7579 7579 78 7579 3 7579 45 7579 7579 100 7579 77 7579 7579 7579 2 7579 31 81 50 67 7579 757...

output:

NNNNSNSNNNSNSSNNNSNNNNNNNSNSNSSNNNSNNNNNNNSNNSNSNSNNSNSNNNSNSSSSNNSSSNNNNNSNNNNSNNNSNNSSNSNNSNNNSNNNNNNNNNNNNSNNSNNNNSSSSNNNNNSNSNSNNNNNNNSNSNNSNSNSSNNSNNNNNNNNNNNNNNNSNNNSNSNSNSSNNSNNSNSSSSNNNNSSNNNNNSNSNNNNSSNNNNNNNNNSSNSNNNSNNNNNNNNSNNSSNSNSNNNSSNNNSNSNNSSSNNNNNNNNSNSNNNNNNSSNNNNSNNNNSNNSNNNSNNNN...

result:

ok accepted

Test #32:

score: 0
Accepted
time: 158ms
memory: 15348kb

input:

100000 189998 50000
9766 3000 3000 3000 3000 3000 99 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 90 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 3000...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #33:

score: 0
Accepted
time: 128ms
memory: 14568kb

input:

100000 169998 100000
8930 8701 8701 8701 8701 8701 8701 8701 8701 1 8701 39 8701 8701 33 8701 8701 8701 8701 8701 8701 8701 12 8701 8701 8701 8701 8701 8701 94 8701 8701 55 8701 50 37 8701 8701 8701 95 8701 8701 8701 8701 57 8701 6 8701 37 44 79 8701 8701 8701 20 8701 8701 8701 8701 8701 8701 8701 8...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #34:

score: 0
Accepted
time: 113ms
memory: 15400kb

input:

100000 199995 50000
479 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1607 1...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted

Test #35:

score: 0
Accepted
time: 121ms
memory: 15396kb

input:

100000 199995 50000
3223 6185 3024 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 3161 ...

output:

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

result:

ok accepted