QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#611667#7030. Ultraman vs. Aodzilla and Bodzillaucup-team4906#WA 1ms7612kbC++203.9kb2024-10-04 22:02:392024-10-04 22:02:39

Judging History

你现在查看的是最新测评结果

  • [2024-10-04 22:02:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7612kb
  • [2024-10-04 22:02:39]
  • 提交

answer

#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define pii pair<int, int> 
#define fi first
#define se second

using namespace std;
const int N = 3e5 + 10;
int n, m, is_q[N];
pii a[N];
pii res[N];

void sol() {
    cin >> n >> m;
    F(i, 1, n) {
        int x, y; cin >> x >> y;
        a[i] = {x, y};
    }
    if(n == 1) {
        F(i, 1, m) {
            char op; cin >> op;
            if(op == '!') cout << "0\n";
            else if(op == '?') {
                int x; cin >> x;
                cout << 1 << " " << 1 << "\n";
            }
        }
        return;
    }
    int x1 = 1, y1 = 1, x2 = n, y2 = n, fx1 = 1, fx2 = n, fy1 = 1, fy2 = n;
    int f1 = 0, f2 = 0;
    // x1: 包含了哪些位置 fx1: 目前的实际位置 
    // f1 是否合并上下的 只保留fx1
    int tot1 = 0, tot2 = 0;
    F(i, 1, m) {
        char op; cin >> op;
        if(op == '!') {
            
        } else if(op == '?') {
            is_q[i] = 2;
            int p; cin >> p;
            auto [x, y] = a[p];
            if(f1) x = fx1;
            else if(x <= x1) x = fx1;
            else if(x >= x2) x = fx2;
            else x -= tot1;
            if(f2) x = fy1;
            else if(y <= y1) y = fy1;
            else if(y >= y2) y = fy2;
            else y -= tot2;
            res[i] = {x, y}; 
        } else {
            is_q[i] = 1;
            int x; cin >> x;
            if(op == 'U') {
                tot1 += x;
                if(f1) { // 当前已经合并了
                    fx1 = max(1, fx1 - x);
                    continue;
                }
                // 挪到1的位置
                int nd = min(fx1 - 1, x);
                x -= nd; 
                fx1 -= nd, fx2 -= nd;
                while(x) {
                    x1 ++, fx2 --;
                    if(x1 == x2) {
                        assert(fx2 == 1);
                        f1 = 1;
                        break;
                    }
                    x --;
                }
            } else if(op == 'D') {
                tot1 -= x;
                if(f1) {
                    fx1 = min(n, fx1 + x);
                    continue;
                }
                int nd = min(n - fx2, x);
                x -= nd; 
                fx1 += nd, fx2 += nd;
                while(x) {
                    x2 --, fx1 ++;
                    if(x1 == x2) {
                        assert(fx1 == n);
                        assert(fx1 == fx2);
                        f1 = 1;
                        break;
                    }
                    x --;
                }
            } else if(op == 'L') {
                tot2 += x;
                if(f2) {
                    fy1 = max(1, fy1 - x);
                    continue;
                }
                int nd = min(fy1 - 1, x);
                x -= nd; 
                fy1 -= nd, fy2 -= nd;
                while(x) {
                    y1 ++, fy2 --;
                    if(y1 == y2) {
                        assert(fy2 == 1);
                        f2 = 1;
                        break;
                    }
                    x --;
                }
            } else {    
                tot2 -= x;
                if(f2) {
                    fy1 = min(n, fy1 + x);
                    continue;
                }
                int nd = min(n - fy2, x);
                x -= nd; 
                fy1 += nd, fy2 += nd;
                while(x) {
                    y2 --, fy1 ++;
                    if(x1 == x2) {
                        assert(fy1 == n);
                        assert(fy1 == fy2);
                        f2 = 1;
                        break;
                    }
                    x --;
                }
            }
        }
    }
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t; cin >> t;
    F(i, 1, t) sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7612kb

input:

2
5 15 5 25
5 15 25 5

output:


result:

wrong output format Unexpected end of file - token expected