QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586322#4218. Hidden GraphciuimWA 1ms4116kbC++142.9kb2024-09-24 10:49:482024-09-24 10:49:49

Judging History

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

  • [2024-09-24 10:49:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4116kb
  • [2024-09-24 10:49:48]
  • 提交

answer

bool M1;
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<" MB\n"
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <array>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
#include <ctime>
#include <cstdlib>
#include <random>
#include <set>
#include <ctime>
#include <map>
#include <stack>
#include <unordered_map>
#include <assert.h>
#define i128 __int128
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define fo(a,b,c) for(ll a=b;a<=c;++a)
#define re(a,b,c) for(ll a=b;a>=c;--a)
#define pii pair<ll,ll>
#define pdd pair<db,db>
#define fi first
#define pb push_back
#define se second
#define ite set<pii> ::iterator
#define vite vector<ll> ::iterator
using namespace std;
const ll mod=998244353;
inline ll gi()
{
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = (x<<1) + (x<<3) + (ch^48);
		ch = getchar();
	}
	return x * f;
}
ll _=1;
const ll inf=2e17+5,iinf=2e9;
const ll N=3005;
ll n;
vector<ll> vec[N];
ll ot(vector<ll> z,ll id)
{
	ll sz=z.size();
	sz++;
	cout<<"? "<<sz<<" ";
	for(ll x:z) cout<<x<<" ";
	cout<<id<<'\n';
	fflush(stdout);
	ll x=gi(),y=gi();
	if(x==id) return y;
	return x;
}
vector<ll> g[N];
ll d[N],lk[N][N],vis[N],col[N],buk[N],k,cnt=0;
void wk(ll len)
{
	cnt=0;
	fo(i,1,len) d[i]=g[i].size(),vis[i]=0,col[i]=0;
	set<pii> s;
	fo(i,1,len) s.insert({d[i],i}),k=max(k,d[i]+1);
	vector<ll> od;
	while(!s.empty())
	{
		pii p=*s.begin();
		s.erase(p);
		ll u=p.se;
		if(vis[u]) continue;
		vis[u]=1;
		od.pb(u);
		for(ll v:g[u])
		{
			if(vis[v]) continue;
			d[v]--;
			s.insert({d[v],v});
		}
	}
	while(od.size())
	{
		ll u=od.back();
		od.pop_back();
		ll sz=g[u].size();
		fo(i,1,sz) buk[i]=0;
		for(ll v:g[u])
		{
			buk[col[v]]=1;
		}
		fo(i,1,k)
		{
			if(buk[i]==0)
			{
				col[u]=i;
				vec[col[u]].pb(u);
				cnt=max(cnt,i);
				break;
			}
		}
	}
//	cout<<"WK "<<len<<" "<<cnt<<'\n';
}
void sol()
{
	n=gi();
	cnt=1;
	vec[1].pb(1);
	k=1;
	fo(i,2,n)
	{
		fo(j,1,cnt)
		{
			while(1)
			{
				if(vec[j].empty()) break;
				ll p=ot(vec[j],i);
				if(p==-1)
				{
					break;
				}
				g[i].pb(p);
				g[p].pb(i);
				lk[i][p]=lk[p][i]=1;
				vector<ll> zs;
				for(ll x:vec[j])
				{
					if(x==p) continue;
					zs.pb(x);
				}
				vec[j]=zs;
			}
		}
		fo(j,1,cnt) vec[j].clear();
		wk(i);
	}
	cout<<"! "<<n<<'\n';
	fo(i,1,n)
	{
		fo(j,i+1,n)
		{
			if(lk[i][j]) cout<<i<<" "<<j<<'\n';
		}
	}
	fflush(stdout);
}
bool M2;
int main()
{
	int Time=clock();
	look_memory;
//	_=gi();
	while(_--)
	{
		sol();
		printf("\n");
	}
	look_time;
	return 0;
}

详细

Test #1:

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

input:

3
1 2
2 3
1 3

output:

? 2 1 2
? 2 2 3
? 2 1 3
! 3
1 2
1 3
2 3


result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4116kb

input:

10
1 2
-1 -1
1 3
-1 -1
1 4
4 5
2 5
-1 -1
-1 -1
-1 -1
2 6
-1 -1
-1 -1
-1 -1
-1 -1
3 7
-1 -1
3 8
4 8
-1 -1
-1 -1
3 9
-1 -1
-1 -1
4 10
3 10
-1 -1

output:

? 2 1 2
? 2 2 3
? 2 1 3
? 3 3 2 4
? 2 1 4
? 4 4 3 2 5
? 3 3 2 5
? 2 3 5
? 2 1 5
? 3 5 1 6
? 3 4 2 6
? 2 4 6
? 2 3 6
? 4 5 1 6 7
? 3 4 2 7
? 2 3 7
? 5 5 1 7 6 8
? 4 4 2 3 8
? 3 4 2 8
? 2 2 8
? 6 8 1 5 7 6 9
? 4 4 3 2 9
? 3 4 2 9
? 7 8 1 5 9 7 6 10
? 4 4 3 2 10
? 3 3 2 10
? 2 2 10
! 10
1 2
1 3
1 4
2 5...

result:

wrong answer read 10 edges but expected 12 edges