QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#160315 | #7107. Chaleur | ucup-team1453# | AC ✓ | 124ms | 10972kb | C++14 | 1.5kb | 2023-09-02 20:05:06 | 2023-09-02 20:05:08 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define sz(a) ((int) a.size())
#define vi vector<int>
#define ll long long
#define me(f, x) memset(f, x, sizeof(f))
#define ull unsigned long long
using namespace std;
const int N = 4e5 + 7;
int n, m;
int deg[N];
ll sum[N];
ll pre[N];
int cnt[N], cur[N];
int ord[N];
int su[N], sv[N], vis[N];
void Main() {
cin >> n >> m;
L(t, 1, m) {
int u, v;
cin >> u >> v;
su[t] = u, sv[t] = v;
++deg[u];
++deg[v];
}
L(i, 1, n) ord[i] = i;
sort(ord + 1, ord + n + 1, [&](int x, int y) {
return deg[x] > deg[y];
});
L(i, 1, n)
pre[i] = pre[i - 1] + deg[ord[i]];
int pos = -1;
R(i, n, 0) {
if(pre[i] == (ll) i * (i - 1) / 2 + m) {
pos = i;
break;
}
}
L(i, 1, pos) vis[ord[i]] = 1;
ll cnt1 = 0, cnt2 = 0;
L(i, 1, n) {
if(vis[i]) {
if(deg[i] == pos - 1) {
++cnt2;
}
} else {
if(deg[i] == pos) {
++cnt1;
}
}
}
if(!cnt1) {
cnt1 = 1;
L(i, 1, n) if(!vis[i] && deg[i] == pos - 1) ++cnt1;
}
if(!cnt2) {
cnt2 = 1;
L(i, 1, n) if(vis[i] && deg[i] == pos) ++cnt2;
}
// L(i, 1, n) cout << vis[i];
// cout << " : ";
cout << cnt1 << ' ' << cnt2 << '\n';
L(i, 1, n) {
deg[i] = 0, vis[i] = 0;
}
}
int main() {
ios :: sync_with_stdio (false);
cin.tie (0); cout.tie (0);
int t; cin >> t; while(t--) Main();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7788kb
input:
3 3 2 1 2 2 3 6 6 1 2 2 3 1 3 1 4 2 5 3 6 4 1 1 2
output:
2 1 1 4 1 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 124ms
memory: 10972kb
input:
2231 1 0 5 7 4 1 3 4 3 1 3 5 4 2 3 2 4 5 5 4 2 1 2 5 2 4 2 3 5 10 3 2 2 5 1 4 4 2 4 5 1 2 1 3 3 5 3 4 1 5 5 10 1 3 2 4 1 4 5 2 2 3 1 5 5 4 1 2 3 4 5 3 5 9 2 5 3 5 2 3 2 1 4 3 3 1 4 1 4 5 2 4 5 4 4 2 4 1 4 5 4 3 5 9 4 1 4 5 3 4 2 4 2 1 3 1 2 5 3 5 3 2 5 4 2 5 2 3 2 1 2 4 5 9 5 2 1 3 4 3 1 2 5 4 4 2 5...
output:
1 1 3 1 4 1 1 5 1 5 2 1 4 1 2 1 4 1 2 1 2 1 3 1 4 1 4 1 1 5 2 1 4 1 1 5 1 5 1 5 3 1 4 1 4 1 4 1 3 1 3 1 4 1 4 1 2 1 4 1 4 1 1 5 1 5 2 1 4 1 4 1 4 1 3 1 2 1 4 1 2 1 4 1 4 1 4 1 3 1 1 5 4 1 4 1 1 5 2 1 4 1 2 1 2 1 1 5 4 1 1 5 3 1 4 1 1 5 2 1 1 5 3 1 3 1 1 5 3 1 3 1 2 1 1 5 4 1 3 1 1 5 2 1 3 1 2 1 2 1 ...
result:
ok 2231 lines
Extra Test:
score: 0
Extra Test Passed