QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#673353 | #9221. Missing Boundaries | ucup-team191# | RE | 0ms | 0kb | C++23 | 1.2kb | 2024-10-24 21:52:29 | 2024-10-24 21:52:29 |
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
int t,n,c;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>t;
while (t--)
{
cin>>n>>c;
vector<pair<int,pii>> v;
int cm=0,ma=c;
while (n--)
{
int l,r;
cin>>l>>r;
if (l==-1 && r==-1)
{
++cm;
continue;
}
if (l==-1)
{
v.pb({r,{l,r}});
--ma;
continue;
}
if (r==-1)
{
v.pb({l,{l,r}});
--ma;
continue;
}
ma-=r-l+1;
v.pb({l,{l,r}});
}
sort(all(v));
bool ok=1;
int mi=0;
if (v[0].y.x!=-1 && v[0].y.x!=1) ++mi;
if (v.back().y.y!=c && v.back().y.y!=-1) ++mi;
for (int i=0;i<(int)v.size()-1;++i)
{
if (max(v[i].y.x,v[i].y.y)>=v[i+1].x)
{
ok=0;
break;
}
if (v[i].y.y!=-1 && v[i+1].y.x!=-1 && v[i+1].y.x!=v[i].y.y+1) ++mi;
}
if (cm<mi || cm>ma) ok=0;
if (ok) cout<<"TAK\n";
else cout<<"NIE\n";
}
}
詳細信息
Test #1:
score: 0
Runtime Error
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