QOJ.ac

QOJ

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#1206#764562#21692. 【NOIP Round #3】移除石子CmsMartinCmsMartinFailed.2024-11-20 10:26:282024-11-20 10:26:43

Details

Extra Test:

Accepted
time: 3ms
memory: 3656kb

input:

20
482
484905008 146395076
281487409 827788926
695067347 393854334
349962478 48012611
510528567 982602415
550510345 831852714
421069828 98275204
781169250 719934190
654527759 504030327
324116270 738182078
536919278 646427132
655595404 765946637
19936404 767361966
209875776 236075621
643910129 105973...

output:

YES
996649706 18767984 1848395951 870514229
993852026 219311822 1730783710 956243506
992604457 515691227 1013639494 536726264
989532072 9307419 1494482656 514258003
989271520 159481135 1367897943 538107558
984715289 418817345 1134764306 568866362
982474990 104713382 1768441141 890679533
977802219 31...

result:

ok OK (20 test cases)

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#764562#21692. 【NOIP Round #3】移除石子CmsMartin100 ✓29ms3712kbC++171.8kb2024-11-20 09:45:532024-11-20 09:45:53

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
#define x first
#define y second

int n;
pair<int, int> a[N];
void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
    sort(a + 1, a + 1 + n);
    cout << "YES\n";
    while (n) {
        auto X = a[n], Y = a[n - 1];
        if (X.x == Y.x) cout << Y.x << " " << Y.y << " " << Y.x + X.y - Y.y << " " << X.y << "\n";
        else if (Y.y <= X.y) {
            int l = max(X.x - Y.x, X.y - Y.y);
            cout << Y.x << " " << Y.y << " " << Y.x + l << " " << Y.y + l << "\n";
        } 
        else if (n > 2) {
            auto& Z = a[n - 2];
            if (Z.x == Y.x) {
                if (Z.y > X.y) {
                    cout << Z.x << " " << Z.y << " " << Z.x + Y.y - Z.y << " " << Y.y << "\n",  Z = X;
                } else if (Z.y == X.y) {
                    int dx = X.x - Z.x, dy = Y.y - Z.y;
                    if (dx >= dy) cout << Z.x - 1 << ".5 " << Z.y << " " << Z.x + dy - 1 << ".5 " << Y.y << "\n", Z = X;
                    else cout << Z.x << " " << Z.y << " " << X.x << " " << Z.y + dx << "\n", Z = Y;
                } else {
                    int l = max(X.x - Y.x, Y.y - X.y);
                    cout << Y.x << " " << X.y << " " << Y.x + l << " " << X.y + l << "\n";
                }
            } else {
                int l = max(X.x - Y.x, Y.y - X.y);
                cout << Y.x << " " << X.y << " " << Y.x + l << " " << X.y + l << "\n";
            }
        } 
        else {
            int l = max(X.x - Y.x, Y.y - X.y);
            cout << Y.x << " " << X.y << " " << Y.x + l << " " << X.y + l << "\n";
        }
        n -= 2;
    }
        
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int T; cin >> T;
    while (T--) solve();
    return 0;
}