제출 #292231

#제출 시각아이디문제언어결과실행 시간메모리
292231davooddkareshki어르신 집배원 (BOI14_postmen)C++17
100 / 100
313 ms31864 KiB
#include<bits/stdc++.h> using namespace std; //#define int long long #define F first #define S second #define pii pair<int,int> #define mpr make_pair #pragma GCC optimize("O1") #pragma GCC optimize("O2") #pragma GCC optimize("O3") #pragma GCC optimize("O4") #pragma GCC optimize("O5") #pragma GCC optimize("O6") #pragma GCC optimize("O7") #pragma GCC optimize("O8") #pragma GCC optimize("O9") #pragma GCC optimize("Ofast") typedef long long ll; const int maxn = 5e5+5; const int mod = 1e9+7; int n, m, k; bitset<maxn> mark_E; int ptr[maxn]; bitset<maxn> mark; int stk[maxn], lst; void DO(int v) { if(mark[v]) { while(stk[lst] != v) { int u = stk[lst]; mark[u] = 0; printf("%d ", u); --lst; } mark[v] = 0; printf("%d\n", v); --lst; } mark[v] = 1; stk[++lst] = v; } int pre[maxn<<1], last[maxn<<1], to[maxn<<1]; void dfs(int v) { while(last[v] != 0) { int id = last[v]; last[v] = pre[id]; if(!mark_E[id>>1]) { mark_E[id>>1] = 1; dfs(to[id]); } } DO(v); } signed main() { //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); scanf("%d%d", &n, &m); for(int i = 1, u, v; i <= m; ++i) { scanf("%d%d", &u, &v); to[i<<1] = v; pre[i<<1] = last[u]; last[u] = (i<<1); to[i<<1|1] = u; pre[i<<1|1] = last[v]; last[v] = (i<<1|1); } dfs(1); } /* 10 15 1 3 5 1 2 3 9 2 3 4 6 3 4 5 7 4 4 8 5 7 8 5 6 7 7 8 8 10 10 9 */

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

postmen.cpp: In function 'int main()':
postmen.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   73 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   76 |         scanf("%d%d", &u, &v);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...