Submission #588276

#TimeUsernameProblemLanguageResultExecution timeMemory
588276Kutan어르신 집배원 (BOI14_postmen)C++14
0 / 100
17 ms27716 KiB
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long , long long>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define dem(x) __builtin_popcount(x)
#define Mask(x) (1LL << (x))
#define BIT(x, i) ((x) >> (i) & 1)
#define ln '\n'
#define io_faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//template <class T>
//inline void read(T& x){
//    bool Neg = false;
//    char c;
//    for (c = getchar(); c < '0'  c > '9'; c = getchar())
//        if (c == '-') Neg = !Neg;
//    x = c - '0';
//    for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
//        x = x * 10 + c - '0';
//    if (Neg) x = -x;
//}
//
//template <class T>
//inline void write(T x)
//{
//    if (x < 0)
//    {
//        putchar('-'); x = -x;
//    }
//    T p = 1;
//    for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
//    for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
//}

const int INF = 1e9 , mod = 1e9 + 7;

template <class T1, class T2>
inline void mul(T1& x, T2 k){ x = (1LL * x * k) % mod; }

template <class T1 , class T2>
inline T1 pw(T1 x, T2 k){T1 res = 1; for (; k ; k >>= 1){ if (k & 1) mul(res, x); mul(x, x); } return res;}

template <class T>
inline bool minimize(T &x, T y){ if (x > y){x = y; return 1;} return 0; }

template <class T>
inline bool maximize(T &x, T y){ if (x < y){x = y; return 1;} return 0; }

#define PROB "a"
void file(){
    if(fopen(PROB".inp", "r")){
        freopen(PROB".inp","r",stdin);
        freopen(PROB".out","w",stdout);
    }
}
void sinh_(){
//    srand(time(0));
//    freopen(PROB".inp" , "w" , stdout);
//    int n;
}
typedef long long ll;
const int N = 5e5 + 5;
int n , m;
unordered_set< int > adj[N];
void readip(){
    cin >> n >> m;
    REP(i, 1, m){
        int u , v; cin >> u >> v;
        adj[u].insert(v);
        adj[v].insert(u);
    }
}
vi res;
stack < int > st;
void solve(){
    st.push(1);
    while(!st.empty()){
        int u = st.top();
        if (adj[u].empty()){
            res.eb(u);
            st.pop();
        }
        else{
            int v = *adj[u].begin();
            st.push(v);
            adj[u].erase(v);
            adj[v].erase(u);
        }
    }
    reverse(ALL(res)); res.pop_back();
    for (int u : res) cout << u << ' ';
}

int main(){
    sinh_();
    io_faster
    file();
    int t = 1;
//    cin >> t;
    while (t--){
        readip();
        solve();
    }
}

Compilation message (stderr)

postmen.cpp: In function 'void readip()':
postmen.cpp:20:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   20 | #define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
      |                            ^
postmen.cpp:85:5: note: in expansion of macro 'REP'
   85 |     REP(i, 1, m){
      |     ^~~
postmen.cpp: In function 'void file()':
postmen.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen(PROB".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(PROB".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...