QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555078#9221. Missing BoundariesThe_Hallak#WA 220ms34816kbC++171.5kb2024-09-09 19:37:022024-09-09 19:37:04

Judging History

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

  • [2024-09-09 19:37:04]
  • 评测
  • 测评结果:WA
  • 用时:220ms
  • 内存:34816kb
  • [2024-09-09 19:37:02]
  • 提交

answer

#include <bits/stdc++.h>

#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long
#define YES "TAK"
#define NO "NIE"
#define endline '\n'

using namespace std;

const ll N = 5e5 + 10, MM = 998244353, MAX = 1e18;

int solve() {
  int n;
  cin >> n;
  ll l;
  cin >> l;
  map<ll, ll> mp;
  map<ll, ll> mp1,mp2;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a + 1) {
      mp[a]++;
      mp1[a] = b;
    }
    if (b + 1&&a!=b) {
      mp[b]++;
      mp2[b] = a;
    }
    if (a == -1 && b == -1) {
      sum++;
    } else if (a + 1 && b + 1) {
      sum += b - a + 1;
    }
  }
  for (auto x : mp)
    if (x.second > 1)
      return cout << NO << endline, 0;
  if (sum > l)
    return cout << NO << endline, 0;

  int cur=1;
  while(mp.size()){
    int mn=mp.begin()->first;
    mp.erase(mp.begin());
    if(mp1.count(mn)){
      if(cur!=mn)return cout<<NO<<endline,0;
      int nxt=mp1[mn];
      if(nxt!=-1){
         cur=nxt+1;
      }else{
        cur=mp.begin()->first;
      }
    }else{
      cur=mn+1;
    }
  }
  cout<<YES<<endline;
  return 0;
}

int main() {
  speed;
  int t = 1;
  cin >> t;
  int i = 1;
  while (t--) {
    // cout << "Case #" << i++ << ": ";
    solve();
  }
  return 0;
}
/*


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 220ms
memory: 34816kb

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: 3556kb

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: 171ms
memory: 31060kb

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'