답안 #146692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146692 2019-08-25T08:24:28 Z MvC Potemkin cycle (CEOI15_indcyc) C++11
30 / 100
1000 ms 4344 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int i,j,bl,x,y,n,m;
bitset<15>b,vz;
vector<int>a[nmax],pth;
void dfs(int x)
{
	int nr=0;
	for(int i=0;i<a[x].size();i++)nr+=b[a[x][i]];
	if(nr!=2)bl=1;
	vz[x]=1;
	pth.pb(x);
	for(int i=0;i<a[x].size();i++)if(b[a[x][i]] && !vz[a[x][i]])dfs(a[x][i]);
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	while(m--)
	{
		cin>>x>>y;
		x--,y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	for(i=1;i<(1<<n);i++)
	{
		if(__builtin_popcount(i)<4)continue;
		b.reset();
		vz.reset();
		for(j=0;j<n;j++)
		{
			if(!(i&(1<<j)))continue;
			b[j]=1;
			x=j;
		}
		bl=0;
		pth.clear();
		dfs(x);
		if(!bl && b.count()==vz.count())
		{
			for(j=0;j<pth.size();j++)if(b[pth[j]])cout<<pth[j]+1<<" ";
			cout<<endl;
			return 0;
		}
	}
	cout<<"no"<<endl;
	return 0;
}

Compilation message

indcyc.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
indcyc.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
indcyc.cpp: In function 'void dfs(int)':
indcyc.cpp:28:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)nr+=b[a[x][i]];
              ~^~~~~~~~~~~~
indcyc.cpp:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)if(b[a[x][i]] && !vz[a[x][i]])dfs(a[x][i]);
              ~^~~~~~~~~~~~
indcyc.cpp: In function 'int main()':
indcyc.cpp:64:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0;j<pth.size();j++)if(b[pth[j]])cout<<pth[j]+1<<" ";
            ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2684 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2680 KB Expected integer, but "no" found
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2680 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2808 KB Output is correct
2 Incorrect 11 ms 2808 KB Expected integer, but "no" found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 2680 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 3448 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 3064 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 4344 KB Time limit exceeded
2 Halted 0 ms 0 KB -