QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#162502 | #7107. Chaleur | ucup-team1209# | AC ✓ | 414ms | 20620kb | C++20 | 1.5kb | 2023-09-03 13:44:10 | 2023-09-03 13:44:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define drep(i,y,x) for (int i=(y);i>=(x);i--)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair
#define templ template<typename T>
templ bool chkmin(T &x,T y){return x>y?x=y,1:0;}
templ bool chkmax(T &x,T y){return x<y?x=y,1:0;}
void file() {
#ifdef zqj
freopen("a.in","r",stdin);
#endif
}
typedef long long ll;
#define sz 101010
int n,m;
vector<int>V[sz];
void work() {
cin>>n>>m;
int x,y;
rep(_,1,m) cin>>x>>y,V[x].push_back(y),V[y].push_back(x);
static int id[sz]; rep(i,1,n) id[i]=i;
sort(id+1,id+n+1,[](int x,int y){return V[x].size()>V[y].size();});
set<int>S;
rep(i,1,n) {
int cnt=0;
for (auto t:V[id[i]]) if (S.count(t)) ++cnt;
if (cnt==(int)S.size()) S.insert(id[i]);
}
int ans1=1;
rep(i,1,n) if (!S.count(i)) {
int cnt=0;
for (auto t:V[i]) if (S.count(t)) ++cnt;
if (cnt==(int)S.size()-1) ++ans1;
}
cout<<ans1<<' ';
set<int>T;
rep(i,1,n) if (!S.count(i)) T.insert(i);
rep(i,1,n) if (S.count(i)&&V[i].size()==S.size()-1) {
T.insert(i);
S.erase(i);
break;
}
int ans2=1;
for (auto x:S) if (V[x].size()==S.size()) ++ans2;
cout<<ans2<<'\n';
rep(i,1,n) V[i].clear();
}
int main() {
file();
ios::sync_with_stdio(false),cin.tie(0);
int T; cin>>T;
while (T--) work();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 6004kb
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: 414ms
memory: 20620kb
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