#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
int n, m, a, b, com[1005], pre[1005], p, N, P;
bool u[1005], u2[1005], adj[1005][1005];
vector<int> v[1005], s;
void dfs(int N){
if (u2[N]) return;
u2[N]=1;
if (u[N]){
s.pb(N);
return;
}
fox(l, v[N].size()) dfs(v[N][l]);
}
queue<pii> q;
void bfs(int S, int T,int L){
q.push(mp(S, -1));
memset(u2, 0, sizeof u2);
u2[L]=1;
while(!q.empty()){
N=q.front().x; P=q.front().y; q.pop();
if (u[N] && N!=T && N!=S) continue;
u2[N]=1; pre[N]=P;
if (N==T) break;
fox(l, v[N].size()){
q.push(mp(v[N][l], N));
}
}
while(T!=S){
cout << T << ' ';
T=pre[T];
}
cout << S << ' ' << L << endl;
}
int main(){
cin >> n >> m;
fox(l, m){
cin >> a >> b;
v[a].pb(b);
v[b].pb(a);
adj[a][b]=adj[b][a]=1;
}
//cout << adj[9][8]+adj[9][10]+adj[6][10]+adj[6][4]+adj[8][4] << endl;
fox1(l, n){
fox1(l2, n){
u[l2]=adj[l][l2];
}
u[l]=1;
memset(u2, 0, sizeof u2);
u2[l]=1;
fox1(l2, n){
if (u[l2] || u2[l2]) continue;
s.clear();
dfs(l2);
fox(l3, s.size()){
for(int l4=l3+1; l4<s.size(); ++l4){
if (!adj[s[l3]][s[l4]]){
bfs(s[l3], s[l4], l);
return 0;
}
}
}
fox(l3, s.size()){
if (u[s[l3]])
u2[s[l3]]=0;
}
}
fox(l2, v[l].size()){
for(int l3=l2+1; l3<v[l].size(); ++l3){
if (!adj[l2][l3] && com[l2]==com[l3]){
}
}
}
}
cout << "no";
return 0;
}
Compilation message
indcyc.cpp: In function 'void dfs(int)':
indcyc.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
indcyc.cpp:37:5: note: in expansion of macro 'fox'
fox(l, v[N].size()) dfs(v[N][l]);
^
indcyc.cpp: In function 'void bfs(int, int, int)':
indcyc.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
indcyc.cpp:49:9: note: in expansion of macro 'fox'
fox(l, v[N].size()){
^
indcyc.cpp: In function 'int main()':
indcyc.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
indcyc.cpp:79:13: note: in expansion of macro 'fox'
fox(l3, s.size()){
^
indcyc.cpp:80:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int l4=l3+1; l4<s.size(); ++l4){
^
indcyc.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
indcyc.cpp:87:13: note: in expansion of macro 'fox'
fox(l3, s.size()){
^
indcyc.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
indcyc.cpp:92:9: note: in expansion of macro 'fox'
fox(l2, v[l].size()){
^
indcyc.cpp:93:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int l3=l2+1; l3<v[l].size(); ++l3){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3040 KB |
Output is correct |
2 |
Correct |
0 ms |
3040 KB |
Output is correct |
3 |
Correct |
0 ms |
3040 KB |
Output is correct |
4 |
Correct |
0 ms |
3040 KB |
Output is correct |
5 |
Correct |
0 ms |
3040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
3040 KB |
Execution timed out |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3040 KB |
Output is correct |
2 |
Correct |
0 ms |
3040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
3040 KB |
Execution timed out |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
8664 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
3172 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
14056 KB |
Execution timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
238476 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
501892 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
1048576 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
5284 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |