제출 #588301

#제출 시각아이디문제언어결과실행 시간메모리
588301KutanSenior Postmen (BOI14_postmen)C++14
100 / 100
414 ms40680 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 "b"
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;
vpii adj[N];
void readip(){
    cin >> n >> m;
    REP(i, 1, m){
        int u, v; cin >> u >> v;
        adj[u].eb(v, i);
        adj[v].eb(u, i);
    }
}

bool vis[N] , used[N] , nxt;
int node[N] , id;

void solve(){
    REP(i, 1, n){
        node[id = 1] = i;
        nxt = 0;
        while(id != 0){
            nxt = 0;
            int u = node[id];
            vis[u] = 1;

            while(!adj[u].empty()){

                int e = adj[u].back().se , v = adj[u].back().fi;
                adj[u].pop_back();

                if (used[e]) continue;
                used[e] = true;

                if (vis[v]){
                    while(node[id] != v){
                        cout << node[id] << ' ';
                        vis[node[id]] = 0;
                        --id;
                    }
                    cout << v << ln;
                }
                else{
                    node[++id] = v;
                }

                nxt = 1;
                break;
            }
            if (!nxt) --id;
        }
    }
}

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

컴파일 시 표준 에러 (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 solve()':
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:96:5: note: in expansion of macro 'REP'
   96 |     REP(i, 1, n){
      |     ^~~
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...