QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#421294#961. Smol Vertex CoverCarroT1212Compile Error//C++142.9kb2024-05-25 16:13:542024-05-25 16:13:55

Judging History

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

  • [2024-05-25 16:13:55]
  • 评测
  • [2024-05-25 16:13:54]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std; bool MEM;
using ll=long long; using ld=long double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
const int I=1e9;
const ll J=1e18,N=507;
ll n,m,a[N],b[N],mch[N],vis[N],ans;
ld st;
vector<ll> e[N];
vector<pll> v;
mt19937 dnr(time(0));
bool hun(ll p) {
	shuffle(e[p].begin(),e[p].end(),dnr);
	vis[p]=1;
	for (ll i:e[p]) {
		ll j=mch[i];
		if (!j) return vis[i]=1,mch[p]=i,mch[i]=p,1;
		if (vis[j]) continue;
		mch[p]=i,mch[i]=p,mch[j]=0;
		if (hun(j)) return 1;
		mch[i]=j,mch[j]=i,mch[p]=0;
	}
	return 0;
}
void fnd() {
	memset(mch,0,sizeof(mch)),v.clear();
	ll flg=1;
	while ((clock()-st)/CLOCKS_PER_SEC<0.1) {
		flg=ans;
		for (ll i=1;i<=n;i++) if (!mch[i]) fill(vis+1,vis+n+1,0),ans+=hun(i);
		flg=ans-flg;
	}
	for (ll i=1;i<=n;i++) if (mch[i]>i) v.pb({i,mch[i]});
}
namespace T {
	const ll N=507;
	ll n,ans[N];
	ll dfn[N<<1],low[N<<1],co[N<<1],cnn,cno;
	vector<ll> e[N<<1];
	stack<ll> st;
	void ini(ll _n) {
		n=_n,cnn=cno=0;
		for (ll i=1;i<=n*2;i++) dfn[i]=co[i]=0;
	}
	void clr() { for (ll i=1;i<=n*2;i++) e[i].clear(); }
	void dda(ll x,ll a,ll y,ll b) { e[x+n*!a].pb(y+n*b); }
	void led(ll x,ll a,ll y,ll b) { e[x+n*!a].pop_back(); }
	void add(ll x,ll a,ll y,ll b) { dda(x,a,y,b),dda(y,b,x,a); }
	void del(ll x,ll a,ll y,ll b) { led(x,a,y,b),led(y,b,x,a); }
	void tar(ll p) {
		dfn[p]=low[p]=++cnn,st.push(p);
		for (ll i:e[p]) {
			if (!dfn[i]) tar(i),low[p]=min(low[p],low[i]);
			else if (!co[i]) low[p]=min(low[p],dfn[i]);
		}
		if (dfn[p]==low[p]) {
			cno++;
			while (st.top()!=p) co[st.top()]=cno,st.pop();
			co[p]=cno,st.pop();
		}
	}
	bool sat() {
		for (ll i=1;i<=n*2;i++) if (!dfn[i]) tar(i);
		for (ll i=1;i<=n;i++) {
			if (co[i]==co[i+n]) return 0;
			ans[i]=!(co[i]<co[i+n]);
		}
		return 1;
	}
}
bool solve() {
	if (T::ini(n),T::sat()) {
		vector<ll> ans;
		for (ll i=1;i<=n;i++) if (T::ans[i]) ans.pb(i);
		cout<<ans.size()<<"\n";
		for (ll i:ans) cout<<i<<" "; cout<<"\n";
		return 1;
	}
	return 0;
}
void mian() {
	scanf("%lld%lld",&n,&m);
	for (ll i=1,x,y;i<=m;i++) scanf("%lld%lld",&x,&y),e[x].pb(y),e[y].pb(x),a[i]=x,b[i]=y;
	st=clock();
	fnd();
	T::clr(),T::ini(n);
	for (ll i=1;i<=m;i++) for (pll i:v) T::add(a[i],1,b[i],1);
//	solve();
	for (ll i=1;i<=n;i++) if (!mch[i]) T::dda(i,0,i,0);
	for (pll i:v) T::add(i.fi,0,i.se,0);
	if (solve()) return;
	for (ll i=1;i<=n;i++) {
		if (!mch[i]) T::led(i,0,i,0);
		else T::del(i,0,mch[i],0);
		T::dda(i,1,i,1);
		if (solve()) return;
		T::led(i,1,i,1);
		if (!mch[i]) T::dda(i,0,i,0);
		else T::add(i,0,mch[i],0);
	}
	cout<<"not smol\n";
}
bool ORY; int main() {
    // while (1)
//     int t; for (scanf("%d",&t);t--;)
    mian();
    cerr<<"\n"<<abs(&MEM-&ORY)/1048576<<"MB "<<clock()<<"ms";
    return 0;
}
/*
3

5 5
1 2
2 3
3 4
4 5
1 5

3 0

5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

*/

Details

answer.code: In function ‘void mian()’:
answer.code:90:53: error: no match for ‘operator[]’ (operand types are ‘ll [507]’ {aka ‘long long int [507]’} and ‘pll’ {aka ‘std::pair<long long int, long long int>’})
   90 |         for (ll i=1;i<=m;i++) for (pll i:v) T::add(a[i],1,b[i],1);
      |                                                     ^
answer.code:90:60: error: no match for ‘operator[]’ (operand types are ‘ll [507]’ {aka ‘long long int [507]’} and ‘pll’ {aka ‘std::pair<long long int, long long int>’})
   90 |         for (ll i=1;i<=m;i++) for (pll i:v) T::add(a[i],1,b[i],1);
      |                                                            ^
answer.code:85:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   85 |         scanf("%lld%lld",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
answer.code:86:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |         for (ll i=1,x,y;i<=m;i++) scanf("%lld%lld",&x,&y),e[x].pb(y),e[y].pb(x),a[i]=x,b[i]=y;
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~