QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#164287#7105. Pixel Artucup-team956Compile Error//C++203.9kb2023-09-04 21:16:292023-09-04 21:16:29

Judging History

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

  • [2023-09-04 21:16:29]
  • 评测
  • [2023-09-04 21:16:29]
  • 提交

answer

#include<bits/stdc++.h>
// #include<bits/extc++.h>
#define time chrono::system_clock::now().time_since_epoch().count()
#define maxn 1000005
// #define int long long
using namespace std;
// using namespace __gnu_pbds;
mt19937_64 rnd(time);

// int read() {int x;cin>>x;return x;}
int read() {
    int x=1,res=0;
    char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') x=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        res=res*10+(c-'0');
        c=getchar();
    }
    return res*x;
}
 
void print(int x) {
    if(x/10) print(x/10);
    putchar(x%10+'0'); 
}

struct node {
    int r1, c1, r2, c2;
};
struct seg {
    int l, r, val, t;
};
bool operator<(seg a, seg b) {
    return a.l < b.l;
}
int tot = 0;
void solve() {
    int n = read(), m = read(), k = read();
    vector<node>a(k + 1);
    vector<vector<seg>>b(n + 1);
    vector<int>sum(n + 2);
    for(int i = 1; i <= k; i++) {
        int r1 = read(), c1 = read(), r2 = read(), c2 = read();
        a[i] = {r1, c1 ,r2, c2};
        if(r1 == r2) {
            int val = c2 - c1 + 1;
            sum[r1] += val;
            sum[r1 + 1] -= val;
            b[r1].push_back({c1, c2, i, r1 + 1});
        }
        else if(c1 == c2) {
            sum[r1] += 1;
            sum[r2 + 1] -= 1;
            b[r1].push_back({c1, c1, i, r2 + 1});
        }
    }
    for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + sum[i];
    for(int i = 1; i <= n; i++) {
        sort(b[i].begin(), b[i].end());
    }
    vector<pair<int,int>>ans(n + 1);
    int res = 0;
    for(int i = 1; i <= n; i++) {
        res += sum[i];
        ans[i].first = res;
    }

    int cnt = 0, del = 0;
    vector<int>f(k + 1);
    for(int i = 1; i <= k; i++) f[i] = i;
    auto fi = [&](auto fi, int x) -> int {
        if(x != f[x]) f[x] = fi(fi, f[x]);
        return f[x];
    };

    // int tot = 0;
    set<seg>s;
    vector<vector<seg>>dele(n + 2);
    for(int i = 1; i <= n; i++) {
        cnt += b[i].size();
        // cout<<"cnt"<<cnt<<"\n";
        int pl = -1, pr = -1, pid = -1;
        for(auto [l, r, id, ti]:b[i]) {
            if(pr != -1 && pr == l - 1 && pid != -1) {
                int fa = fi(fi, pid);
                int fb = fi(fi, id);
                if(fa != fb) {
                    // cout<<fa<<" "<<fb<<"!!\n";
                    del ++;
                    f[fa] = fb;
                }
            }
            pr = r;
            pid = id;
            seg x = {l, r, id, ti};
            auto it = s.lower_bound(x);
            if(it != s.begin()) it --;
            // cout<<"i:"<<i<<"\n";
            // cout<<it->l<<" "<<it->r<<" "<<it->val<<"\n";
            
            for(;it != s.end(); it++) {
                // tot++;
                // if(tot > 2e5) return;
                if((!(l > it -> r) && !(r < it - > l))  
                || (it -> t > i && l == it -> r + 1) || (it -> t > i && r == it -> l - 1)) {
                    int fa = fi(fi, it->val);
                    int fb = fi(fi, id);
                    if(fa != fb) {
                        // cout<<fa<<" "<<fb<<"!!\n";
                        del ++;
                        f[fa] = fb;
                    }
                }
                if(it -> l > r) break;
            }
        }
        for(auto segm:dele[i]) {
            s.erase(segm);
        }

        for(auto segm:b[i]) {
            s.insert(segm);
            int ti = segm.t;
            dele[ti].push_back(segm);
        }
        ans[i].second = cnt - del;
    }

    for(int i = 1; i <= n; i++) {
        auto [x, y] = ans[i];
        print(x);
        cout<<" ";
        print(y);
        cout<<"\n";
        // cout << x << " " << y << "\n";
    }
}

signed main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0); 
    int t = read();
    while(t--) solve();
    return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:107:50: error: expected primary-expression before ‘>’ token
  107 |                 if((!(l > it -> r) && !(r < it - > l))
      |                                                  ^