제출 #135924

#제출 시각아이디문제언어결과실행 시간메모리
135924Zex어르신 집배원 (BOI14_postmen)C++11
38 / 100
431 ms8448 KiB
#include<bits/stdc++.h> using namespace std; #define LL long long #define INF INT_MAX #define output for(int i=1;i<=N;i++) { for(int j=1;j<=N;j++) { cout << adj[i][j] << " "; }cout<<endl; }cout<<endl; const int maxN = 2001; int N, M; bool adj[maxN][maxN]; vector < vector<int> > res; vector <int> path; bool visited[maxN]; int root; bool foundCycle; void dfs( int p, int x ){ // cout << p << " -> " << x << endl; if( x == root ){ // cout << "FOUND ROOT" << endl; foundCycle = true; adj[x][p] = adj[p][x] = false; return; } if( visited[x] ) return; visited[x] = true; for(int j=1;j<=N;j++){ if( j == p || j == x ) continue; if( !adj[x][j] ) continue; adj[x][j] = adj[j][x] = false; dfs( x, j ); if( foundCycle ){ // cout << "FOUND ROOT, DISABLE " << p << "->" << x << " AND " << x << "->" << j << endl; path.push_back(j); return; } adj[x][j] = adj[j][x] = true; } } void printVec( vector <int> v ){ for(int i=0;i<v.size()-1;i++) cout << v[i] << " "; cout << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); memset( adj, 0, sizeof adj ); cin >> N >> M; int x, y; for(int i=0;i<M;i++){ cin >> x >> y; adj[x][y] = adj[y][x] = true; } for(int i=1;i<=N;i++) for(int j=1;j<=N;j++){ if( !adj[i][j] ) continue; adj[i][j] = adj[j][i] = false; memset( visited, 0, sizeof visited ); path.clear(); root = i; foundCycle = false; dfs( i, j ); path.push_back( j ); path.push_back( i ); if( path.size() == 2 ) continue; reverse( path.begin(), path.end() ); // printVec( path ); // output; res.push_back(path); } for(int i=0;i<res.size();i++){ printVec( res[i] ); } }

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp: In function 'void printVec(std::vector<int>)':
postmen.cpp:45:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v.size()-1;i++) cout << v[i] << " ";
                 ~^~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:79:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<res.size();i++){
                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...