QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#691610 | #7898. I Just Want... One More... | HomuraAkemi# | WA | 5ms | 3844kb | C++23 | 1.2kb | 2024-10-31 12:13:42 | 2024-10-31 12:13:45 |
Judging History
answer
// Homura Akemi a.k.a. Starrykiller (/user/235125)
// I love Madoka Kaname forever!
#include <bits/stdc++.h>
using namespace std;
template<typename L, typename R>
auto range(L l, R r) { return views::iota(l,r); }
auto rev=views::reverse;
template<typename T>
_GLIBCXX_ALWAYS_INLINE void chmax(T &a, T b) { a=max(a,b); }
template<typename T>
_GLIBCXX_ALWAYS_INLINE void chmin(T &a, T b) { a=min(a,b); }
#define int long long
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int T; cin>>T;
// int T=1;
while (T--) []{
int n, m; cin>>n>>m;
vector<vector<int>> g(n*2);
for (int i=1,u,v; i<=m; ++i) {
cin>>u>>v;
u--; v--; v+=n;
g[u].push_back(v);
g[v].push_back(u);
}
int l=0, r=0;
int L=0, R=0;
vector<int> vis(2*n);
auto dfs=[&](auto &&self, int u)->void {
if (u<n) l++;
else r++;
vis[u]=1;
for (auto v: g[u]) if (!vis[v]) self(self,v);
};
for (int i=0; i<2*n; ++i) if (!vis[i]) {
l=r=0;
dfs(dfs,i);
if (l>r) L+=l;
if (r>l) R+=r;
}
cout<<L*R<<'\n';
}();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
3 4 3 1 2 3 2 4 3 3 3 1 3 2 2 3 1 3 2 1 2 1 2
output:
6 0 4
result:
ok 3 number(s): "6 0 4"
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3844kb
input:
10000 5 4 2 2 3 1 5 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 3 2 1 1 2 1 1 5 5 1 4 2 2 3 1 1 3 1 2 2 4 2 2 2 1 1 2 1 1 5 1 5 3 3 1 2 2 1 1 1 1 3 2 3 1 2 1 5 2 1 2 2 3 5 3 1 5 4 2 1 2 4 1 1 1 2 3 1 1 2 2 2 1 4 1 1 4 3 1 1 1 1 1 1 1 2 1 2 2 3 3 1 3 2 3 2 2 3 3 1 3 3 3 1 2 3 3 2 2 1 ...
output:
6 0 0 2 0 0 0 0 8 0 16 4 0 6 9 9 9 0 9 4 0 1 1 1 0 4 16 15 3 2 16 0 2 2 20 1 0 0 0 0 16 4 4 16 4 9 0 9 0 2 3 0 9 4 9 16 20 0 0 1 12 0 1 2 0 0 1 0 0 2 2 4 0 12 1 0 0 2 1 2 2 3 0 4 1 6 0 0 0 0 9 16 2 0 1 2 0 12 2 4 0 12 1 1 9 4 6 9 9 12 3 16 15 16 9 4 9 0 1 16 9 9 1 9 16 9 12 4 9 2 0 4 0 6 0 3 0 0 0 0...
result:
wrong answer 9th numbers differ - expected: '6', found: '8'