제출 #288672

#제출 시각아이디문제언어결과실행 시간메모리
288672LordOfIranSenior Postmen (BOI14_postmen)C++17
55 / 100
576 ms59128 KiB
    //                             In The Name Of Allah                                           
    #include <bits/stdc++.h>
    #define	ss second
    #define ff first
    #define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
    #define se(n) cout << setprecision(n) << fixed
    #define pb push_back
    //#define ll long long
    #define ld long double
    #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
    #pragma GCC optimize("no-stack-protector,fast-math")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    using namespace std; 
    const int N = 5e5 + 100, OO = 1e9 + 7, K = 1e7 + 4, T = 22, M = 1e9 + 7, P = 6151, SQ = 1300, lg = 22;
    typedef pair <int, int> pii;
    bool mark[N];
    int num[N], ET[N], l[N], r[N], nw[N], ht[N], nxt = 0;
    vector <int> v[N];
     
    inline void dfs(int x) {
    	for(; nw[x] < (int)v[x].size(); nw[x]++) {
    		int p = v[x][nw[x]];
    		if(mark[p])
    			continue;
    		mark[p] = true;
    		dfs(l[p] ^ r[p] ^ x);
    		ET[nxt++] = x;
    	}
    }
     
    int32_t main() {
    	int n, m;
    	scanf("%d%d", &n, &m);
    	for(int i = 0; i < m; i++) {
    		scanf("%d%d", &l[i], &r[i]);
    		v[r[i]].pb(i);
    		v[l[i]].pb(i);
    	}
    	dfs(1);
    	int sz = -1;
    	for(int i = 0; i < nxt; i++) {
    		int u = ET[i];
    		if(num[u]) {
    			printf("%d", u);
    			while(ht[sz] != u) 	
    				printf(" %d", ht[sz]), num[ht[sz]]--, sz--;
    			cout << "\n";
    		}
    		else 
    			ht[++sz] = u, num[u]++;
    	}
    	for(int i = 0; i <= sz; i++)
    		printf("%d ", ht[i]);
    	return 0;
    }

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

postmen.cpp: In function 'int32_t main()':
postmen.cpp:33:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |      scanf("%d%d", &n, &m);
      |      ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:35:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |       scanf("%d%d", &l[i], &r[i]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...