QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#849081#9310. Permutation Counting 4StarrykillerWA 0ms3560kbC++23965b2025-01-09 11:43:562025-01-09 11:43:56

Judging History

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

  • [2025-01-09 11:43:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2025-01-09 11:43:56]
  • 提交

answer

// Homura Akemi a.k.a. Starrykiller (/user/235125)
// I love Madoka Kaname forever! 
#include <bits/stdc++.h>

using namespace std;

auto range(auto l, auto r) { return views::iota(l,r); }
auto rev=views::reverse;

_GLIBCXX_ALWAYS_INLINE void chmax(auto &a, auto b) { a=max(a,b); }
_GLIBCXX_ALWAYS_INLINE void chmin(auto &a, auto b) { a=min(a,b); }
// #define int long long

struct dsu {
    vector<int> fa;
    dsu() {}
    dsu(int n) { 
        fa.resize(n);
        for (int i=0; i<n; ++i) fa[i]=i;
    }
    int get(int x) { return fa[x]==x?x:fa[x]=get(fa[x]); }
    void merge(int x, int y) { fa[get(x)]=get(y); }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
int T; cin>>T;
// int T=1;
while (T--) []{
    int n; cin>>n;
    dsu d(n+1);
    for (int i=1; i<=n; ++i) {
        int l, r; cin>>l>>r;
        if (d.get(--l)==d.get(r)) {
            cout<<"0\n"; return;
        }
        cout<<1<<'\n';
    }
}();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

input:

4
5
1 2
1 5
1 2
1 2
2 2
5
1 1
2 4
2 3
5 5
3 4
5
3 5
1 2
3 4
3 5
3 3
5
1 5
1 4
4 5
5 5
1 2

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

wrong answer 1st words differ - expected: '0', found: '1'