QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361251 | #7107. Chaleur | YeongTree | AC ✓ | 573ms | 37520kb | C++17 | 1.9kb | 2024-03-23 02:12:53 | 2024-03-23 02:12:53 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <random>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define plll pair<long long, pll>
#define tiii array<int, 3>
#define tiiii array<int, 4>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
typedef long long ll;
const int INF = (int)1e9 + 7;
using namespace std;
unordered_set<int> gph[101010];
int deg[101010];
bool R[101010];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--)
{
int n, m; cin >> n >> m;
for(int i = 0; i < n; ++i) gph[i].clear(), deg[i] = 0, R[i] = false;
for(int i = 0; i < m; ++i)
{
int x, y; cin >> x >> y; --x; --y;
gph[x].insert(y);
gph[y].insert(x);
}
int A[n]; iota(A, A + n, 0);
sort(A, A + n, [&](int x, int y){ return gph[x].size() > gph[y].size(); });
vector<int> V;
for(auto i : A)
{
bool flag = true;
for(auto j : V)
{
if(!gph[i].count(j))
{
flag = false;
break;
}
}
if(!flag) break;
V.push_back(i);
R[i] = true;
}
vector<int> W;
for(int i = 0; i < n; ++i) if(!R[i]) W.push_back(i);
for(auto i : V) for(auto j : gph[i]) if(!R[j]) ++deg[j];
for(auto i : W) for(auto j : gph[i]) if(R[j]) ++deg[j];
int cnt = 0;
for(auto i : W) if(deg[i] == (int)V.size()) ++cnt;
if(cnt) cout << cnt << ' ';
else
{
cnt = 1;
for(auto i : W) if(deg[i] == (int)V.size() - 1) ++cnt;
cout << cnt << ' ';
}
cnt = 0;
for(auto i : V) if(deg[i] == 0) ++cnt;
if(cnt) cout << cnt << '\n';
else
{
cnt = 1;
for(auto i : V) if(deg[i] == 1) ++cnt;
cout << cnt << '\n';
}
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9412kb
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: 573ms
memory: 37520kb
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