QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596502 | #9223. Data Determination | ucup-team1074 | WA | 0ms | 3572kb | C++23 | 3.2kb | 2024-09-28 15:54:49 | 2024-09-28 15:54:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const int inf = 0x3f3f3f3f;
void solve()
{
int n , k;
cin >> n >> k;
if(n > k){
for(int i = 0 ; i < n ; i ++){
int x , y;
cin >> x >> y;
}
cout << "NIE\n";
return;
}
else{
vector< pair<int,int> >p[4];
for(int i = 0 ; i < n ; i ++){
int x , y;
cin >> x >> y;
if(x == -1 && y == -1){
p[3].pb({x , y});
}
else if(x == -1){
p[2].pb({y , x});
}
else if(y == -1){
p[0].pb({x , y});
}
else{
p[1].pb({x , y});
}
}
for(int i = 0 ; i < 4 ; i ++){
sort(p[i].begin() , p[i].end());
}
int st = 1;
int cnt = 0;//可存放机动点的位置
int pos[4];
memset(pos , 0 , sizeof pos);
while(1){
if(pos[0] < p[0].size()){
if(p[0][pos[0]].first < st){
cout <<"NIE\n";
return;
}
else if(p[0][pos[0]].first == st){
pos[0]++;
int mi = inf;
if(pos[0] < p[0].size()){
mi = min(mi , p[0][pos[0]].first);
}
if(pos[1] < p[1].size()){
mi = min(mi , p[1][pos[1]].first);
}
if(pos[2] < p[2].size()){
mi = min(mi , p[2][pos[2]].first);
}
if(mi == inf){
cnt += k - st;
st = k + 1;
break;
}
cnt += mi - st - 1;
if(mi <= st){
cout << "NIE\n";
return;
}
st = mi;
continue;
}
}
if(pos[1] < p[1].size()){
if(p[1][pos[1]].first < st){
cout <<"NIE\n";
return;
}
else if(p[1][pos[1]].first == st){
int mi = p[1][pos[1]].second + 1;
pos[1]++;
st = mi;
continue;
}
}
if(pos[2] < p[2].size()){
if(p[2][pos[2]].first < st){
cout <<"NIE\n";
return;
}
else {
int mi = inf;
if(pos[0] < p[0].size()){
mi = min(mi , p[0][pos[0]].first);
}
if(pos[1] < p[1].size()){
mi = min(mi , p[1][pos[1]].first);
}
if(pos[2] < p[2].size()){
mi = min(mi , p[2][pos[2]].first + 1);
}
if(mi == p[2][pos[2]].first + 1){
cnt += mi - st - 1;
pos[2]++;
if(mi <= st){
cout << "NIE\n";
return;
}
st = mi;
continue;
}
}
}
if(pos[3] < p[3].size()){
p[3].pop_back();
int mi = inf;
if(pos[0] < p[0].size()){
mi = min(mi , p[0][pos[0]].first);
}
if(pos[1] < p[1].size()){
mi = min(mi , p[1][pos[1]].first);
}
if(pos[2] < p[2].size()){
mi = min(mi , p[2][pos[2]].first);
}
if(mi == inf){
cnt += k - st;
st = k + 1;
break;
}
else{
if(mi <= st){
cout << "NIE\n";
return;
}
cnt += mi - st - 1;
st = mi;
}
continue;
}
break;
}
if(st != k + 1){
cout << "NIE\n";
}
else if(cnt >= p[3].size()){
cout <<"TAK\n";
}
else{
cout <<"NIE\n";
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
int t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3572kb
input:
3 6 4 42 41 43 41 57 41 42 4 2 4 1 2 5 8 7 5 57 101 2 42 5 57 7 13
output:
NIE NIE NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'