QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#874495 | #9221. Missing Boundaries | emersonjr02 | WA | 37ms | 9600kb | C++17 | 2.8kb | 2025-01-28 08:41:03 | 2025-01-28 08:41:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sws std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define float long double
#define ld long double
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define in(v) for(auto & x : v) cin >> x;
#define out(v) for(auto x : v) cout << x << ' ';
#define tiii tuple<int, int, int>
const int MAX = 3e5+1;
const int INF = INT32_MAX;
int MOD = 998244353;
const int LOG = 31;
const ld PI = acos(-1);
const int MINF = INT32_MIN;
vpii dirs = {{1, 0}, {-1, 0}};
vpii dirs1 = {{0, 1}, {0, -1}};
// Contest patrocinado por Summer
void solve() {
int n, l, jokers = 0, needToBeFree = 0; cin >> n >> l;
vpii sweep; // {iniInter, -1 ou 1 (l ou r)}
vector<bool> marks(n);
for(int i = 0; i < n; i++){
int li, ri; cin >> li >> ri;
if(ri == li && ri == -1) {jokers++; continue;}
if(ri != -1) sweep.emplace_back(ri, i);
else marks[i] = true;
if(li != -1) sweep.emplace_back(li, -i);
else marks[i] = true;
}
if(n > l){cout << "NIE\n"; return;}
sort(all(sweep));
int last = 0, free = 0;
int opend = -1;
bool flag = false;
for(auto[x, y] : sweep){
// cout << " - " << last << " " << x << '\n';
// cout << free << '\n';
if(last == x && opend != y){cout << "NIE\n"; return;}
if(y > 0){
if(opend == -1){
// cout << "A " << x-last-1 << '\n';
free += x - last - 1;
if(!flag && x-last-1) needToBeFree++;
flag = true;
} else{
if(opend == y){
opend = -1;
last = x;
flag = false;
continue;
}
cout << "NIE\n";
return;
}
last = x;
continue;
}
if(opend != -1){
cout << "NIE\n";
return;
}
opend = -y;
// cout << "B " << x-last-1 << '\n';
free += x - last - 1;
if(marks[-y]) {flag = true; opend = -1;}
if(!flag && x-last-1) needToBeFree++;
last = x;
}
free += l - last;
if(!flag && l - last) needToBeFree ++;
// cout << free << " == " << needToBeFree << '\n';
if(needToBeFree > jokers || free < jokers){cout << "NIE\n"; return;}
cout << "TAK\n";
}
int32_t main() {
sws;
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: 3712kb
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: -100
Wrong Answer
time: 37ms
memory: 9600kb
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:
NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'