QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#787936#9221. Missing Boundariesucup-team2179#WA 38ms17188kbC++231.8kb2024-11-27 15:17:562024-11-27 15:17:57

Judging History

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

  • [2024-11-27 15:17:57]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:17188kb
  • [2024-11-27 15:17:56]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define db double
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 4e5 + 999;
int n, L, m, ok[N], l[N], r[N];
pii p[N];
void solve() {
    cin >> n >> L;
    m = 0;
    int s = 0;
    bool flag = 1;
    for (int i = 1; i <= n; i++){
        cin >> l[i] >> r[i];
        if(l[i] != -1 && r[i] != -1){
            ok[i] = 3;
            p[++m] = make_pair(l[i], i);
        }
        else if(l[i] != -1){
            ok[i] = 1;
            p[++m] = make_pair(l[i], i);
        }
        else if(r[i] != -1){
            ok[i] = 2;
            p[++m] = make_pair(r[i], i);
        }
        else
            s++;
    }
    p[++m] = make_pair(0, m);
    p[++m] = make_pair(L + 1, m);
    ok[m] = ok[m - 1] = 3;
    sort(p + 1, p + m + 1);
    int nd = 0, s1 = 0;
    for (int i = 2; i <= m; i++){
        auto [x, id] = p[i];
        auto [xx, lid] = p[i - 1];
        //cout << id << ' ';
        if(ok[lid] == 3)
            xx = r[lid];
        if(x <= xx){
            flag = 0;
            break;
        }
        if(ok[lid] == 1){
            if(ok[id] == 2){
                s1 += x - xx - 1;
            }
            else {
                s1 += x - xx - 1;
            }
        }
        else {
            if(ok[id] == 2){
                s1 += x - xx - 1;
            }
            else {
                if(x - xx > 1)
                    nd++;
                s1 += (x - xx - 1);
            }
        }
    }
    if(s < nd || s > s1)
        flag = 0;
    if(flag)
        cout << "TAK\n";
    else
        cout << "NIE\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 9808kb

input:

3
4 51
1 -1
11 50
-1 -1
-1 10
3 2
-1 -1
-1 -1
-1 -1
2 3
1 2
2 3

output:

TAK
NIE
NIE

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 38ms
memory: 17188kb

input:

1
200000 1000000000
490669427 -1
224278942 224287156
821104480 -1
861696576 861702036
807438935 807440055
574078002 574083717
465630141 -1
195378188 -1
-1 13500961
-1 977536179
92893115 -1
-1 661145418
-1 215804863
-1 685338515
544348999 -1
465532902 -1
130346949 -1
-1 526666304
635604584 635605404
...

output:

TAK

result:

ok single line: 'TAK'

Test #3:

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

input:

3
4 51
1 -1
11 50
-1 -1
-1 10
3 2
-1 -1
-1 -1
-1 -1
2 3
1 2
2 3

output:

TAK
NIE
NIE

result:

ok 3 lines

Test #4:

score: -100
Wrong Answer
time: 32ms
memory: 16412kb

input:

1
197838 400000
34167 34169
352180 -1
235963 -1
-1 -1
160401 160405
347288 -1
270353 270354
214502 214504
183243 183245
-1 -1
-1 36193
-1 -1
-1 17557
273498 273500
269137 -1
395099 395100
285515 285518
-1 -1
71041 71042
324060 -1
-1 385151
-1 379645
-1 -1
-1 185142
-1 191584
89259 89261
328347 32834...

output:

NIE

result:

wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'