QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163127#7107. ChaleuroscaryangAC ✓73ms43352kbC++172.0kb2023-09-03 21:06:122023-09-03 21:06:13

Judging History

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

  • [2023-09-03 21:06:13]
  • 评测
  • 测评结果:AC
  • 用时:73ms
  • 内存:43352kb
  • [2023-09-03 21:06:12]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define db double
#define vc vector
#define pb emplace_back
#define pii pair<int,int>
#define mkp make_pair
#define mem(a) memset(a,0,sizeof(a))

//#define int long long

using namespace std;
const int N = 1e6+5, P = 998244353;
const int inf = 0x3f3f3f3f;
//const ll inf = 0x3f3f3f3f3f3f3f3f;

inline int read() {
	int x = 0, w = 0; char ch = getchar(); while(!isdigit(ch)) w |= (ch=='-'), ch = getchar();
	while(isdigit(ch)) x = x*10+(ch^48), ch = getchar(); return w?-x:x;
}
inline void write(int x) { if(x<0) putchar('-'), x = -x; if(x>9) write(x/10); putchar(x%10+'0'); }
inline void writec(int x) { write(x); putchar(32); }
inline void writee(int x) { write(x); putchar(10); }

inline void inc(int &x,int y) { x += y-P; x += (x>>31)&P; }
inline void dec(int &x,int y) { x -= y; x += (x>>31)&P; }
inline int pls(int x,int y) { x += y-P; x += (x>>31)&P; return x; }
inline void Max(int &x,int y) { if(x<y) x = y; }
inline void Min(int &x,int y) { if(x>y) x = y; }
inline int power(int a,int b) { int res = 1; for(;b;b>>=1,a=1ll*a*a%P) if(b&1) res = 1ll*res*a%P; return res; }

int n, m, cnt, o[N];
bool vis[N];
pii e[N];
vc<int> G[N];

int TIME;

inline void solve() {
	n = read(); m = read(); ++TIME;
	for(int i=1;i<=n;i++) vis[i] = 0, G[i].clear(), o[i] = i;
	for(int i=1,x,y;i<=m;i++) x = read(), y = read(), G[x].pb(y), G[y].pb(x), e[i] = mkp(x,y);
	sort(o+1,o+1+n,[&](int A,int B){return G[A].size()>G[B].size();});
	int cnt1 = 0, cnt2 = 0, cnt3 = 0; cnt = 0;
	for(int i=1;i<=n;i++) {
		int x = o[i], res = 0;
		for(auto y:G[x]) res += vis[y];
		if(res==cnt) ++cnt, vis[x] = 1;
	}
	for(int i=1;i<=n;i++) if(!vis[i]) assert(G[i].size()<cnt);
	for(int i=1;i<=n;i++) if(vis[i]==1) {
		if(G[i].size()==cnt) ++cnt3;
		else if(G[i].size()==cnt-1) ++cnt1;
	}
	for(int i=1;i<=n;i++) if(vis[i]!=1 && G[i].size()==cnt-1) ++cnt2;
	if(cnt1) cout<<1+cnt2<<" "<<cnt1<<endl;
	else cout<<1+cnt2<<" "<<1+cnt3<<endl;
}

signed main() {
	int t = read(); while(t--)  solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 32976kb

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: 73ms
memory: 43352kb

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