QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#1027 | #663913 | #21692. 【NOIP Round #3】移除石子 | mayike | wth2026 | Failed. | 2024-10-21 18:26:27 | 2024-10-21 18:26:27 |
Details
Extra Test:
Invalid Input
input:
1 4 1 0 1 2 -1 2 5 2
output:
result:
FAIL Integer parameter [name=x] equals to -1, violates the range [0, 10^9] (stdin, line 5)
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#663913 | #21692. 【NOIP Round #3】移除石子 | wth2026 | 100 ✓ | 365ms | 3764kb | C++14 | 2.9kb | 2024-10-21 18:21:43 | 2024-10-21 18:21:44 |
answer
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f
#define lnf 0x3f3f3f3f3f3f3f3f
const bool Debug = false;
#define Debug ture
using namespace std;
void outputl (pair <int, int> x, pair <int, int> y) {
int X = max (x.first, y.first);
int Y = max (x.second, y.second);
int Z = max (abs (x.first - y.first), abs (x.second - y.second));
cout << X - Z << ".5 " << Y - Z << ' ' << X << ".5 " << Y << endl;
}
void outputr (pair <int, int> x, pair <int, int> y) {
int X = max (x.first, y.first);
int Y = max (x.second, y.second);
int Z = max (abs (x.first - y.first), abs (x.second - y.second));
cout << X - Z << ' ' << Y - Z << ' ' << X << ' ' << Y << endl;
}
const int N = 3000 + 5;
int n;
pair <int, int> _Nd[N];
vector <int> _Nw;
void Main () {
cout << "Yes" << endl;
cin >> n;
_Nw.clear ();
for (register int i = 1; i <= n; ++ i) {
cin >> _Nd[i].first >> _Nd[i].second;
_Nw.push_back (i);
}
sort (_Nd + 1, _Nd + n + 1);
while (_Nw.size ()) {
// for (auto it : _Nw) {
// cout << it << ' ';
// }
//
// cout << endl;
//
if (_Nd[_Nw[0]].first == _Nd[_Nw[1]].first || _Nd[_Nw[0]].second < _Nd[_Nw[1]].second || _Nw.size () == 2) {
outputr (_Nd[_Nw[0]], _Nd[_Nw[1]]);
_Nw.erase (_Nw.begin ());
_Nw.erase (_Nw.begin ());
// cout << "HHH" << endl;
// cout <<
} else {
auto Z = _Nw.begin ();
++ Z;
auto Y = Z;
++ Z;
auto X = _Nw.begin ();
// cout << * X << ' ' << _Nd[* X].first << ' ' << _Nd[* X].second << endl;
// cout << * Y << ' ' << _Nd[* Y].first << ' ' << _Nd[* Y].second << endl;
// cout << * Z << ' ' << _Nd[* Z].first << ' ' << _Nd[* Z].second << endl;
//
if (_Nd[* Z].first == _Nd[* Y].first && _Nd[* Z].second < _Nd[* X].second) {
outputr (_Nd[* Y], _Nd[* Z]);
// cout << * Y << ' ' << * Z << endl;
_Nw.erase (Z);
_Nw.erase (Y);
// cout << "HHHHH" << endl;
// exit (0);
} else if (_Nd[* Z].first == _Nd[* Y].first && _Nd[* Z].second == _Nd[* X].second) {
// exit (- 1);
if (_Nd[* Z].second - _Nd[* Y].second > _Nd[* Z].first - _Nd[* X].first) {
outputr (_Nd[* X], _Nd[* Z]);
_Nw.erase (Z);
_Nw.erase (X);
} else if (_Nd[* Z].second - _Nd[* Y].second < _Nd[* Z].first - _Nd[* X].first) {
outputr (_Nd[* Y], _Nd[* Z]);
_Nw.erase (Z);
_Nw.erase (Y);
} else {
outputl (_Nd[* Y], _Nd[* Z]);
_Nw.erase (Z);
_Nw.erase (Y);
}
} else {
outputr (_Nd[* Y], _Nd[* X]);
_Nw.erase (Y);
_Nw.erase (X);
}
}
}
}
signed main () {
// ios :: sync_with_stdio (false);
// cin.tie (0);
// cout.tie (0);
int T;
cin >> T;
while (T --) {
Main ();
}
}
/*
1
10
2 1
1 3
3 3
2 5
3 5
4 3
1 5
5 2
5 1
3 1
*/