Submission #31390

# Submission time Handle Problem Language Result Execution time Memory
31390 2017-08-20T20:44:39 Z imaxblue Senior Postmen (BOI14_postmen) C++14
55 / 100
500 ms 53696 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, m, a, b, t, p[500005];
bool u[500005], u2[500005];
vector<pii> v[500005];
vector<int> s, ans;
void dfs(int N){
    if (u[N]){
        t=-1;
        ans.clear();
        while(t!=N){
            //ans.pb(e.back()); e.pop_back();
            ans.pb(t=s.back()); s.pop_back();
            u[t]=0;
        }
        reverse(ans.begin(), ans.end());
        fox(l, ans.size()) printf("%i ", ans[l]); cout << endl;
    }
    //if (N>64800)
    //cout << N << endl;
    for(; p[N]<v[N].size(); ++p[N]){
        if (!u2[v[N][p[N]].y]){
            u[N]=1;
            s.pb(N);
            u2[v[N][p[N]].y]=1;
            //e.pb(v[N][p[N]].y);
            dfs(v[N][p[N]].x);
        }
    }
}
int main(){
    scanf("%i%i", &n, &m);
    fox(l, m){
        //a=l+1; b=(l==m-1 ? 1:l+2);
        scanf("%i%i", &a, &b);
        v[a].pb(mp(b, l+1));
        v[b].pb(mp(a, l+1));
    }
    dfs(1);
    return 0;
}

Compilation message

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
postmen.cpp:41:13:
         fox(l, ans.size()) printf("%i ", ans[l]); cout << endl;
             ~~~~~~~~~~~~~         
postmen.cpp:41:9: note: in expansion of macro 'fox'
         fox(l, ans.size()) printf("%i ", ans[l]); cout << endl;
         ^~~
postmen.cpp:18:19: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define fox(k, x) for (int k=0; k<x; ++k)
                   ^
postmen.cpp:41:9: note: in expansion of macro 'fox'
         fox(l, ans.size()) printf("%i ", ans[l]); cout << endl;
         ^~~
postmen.cpp:41:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         fox(l, ans.size()) printf("%i ", ans[l]); cout << endl;
                                                   ^~~~
postmen.cpp:45:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(; p[N]<v[N].size(); ++p[N]){
           ~~~~^~~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:56:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12032 KB Output is correct
2 Correct 13 ms 12136 KB Output is correct
3 Correct 12 ms 12032 KB Output is correct
4 Correct 15 ms 12288 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
6 Correct 17 ms 12288 KB Output is correct
7 Correct 20 ms 13032 KB Output is correct
8 Correct 16 ms 12288 KB Output is correct
9 Correct 84 ms 17656 KB Output is correct
10 Correct 20 ms 12288 KB Output is correct
11 Correct 14 ms 12288 KB Output is correct
12 Correct 80 ms 17996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12160 KB Output is correct
2 Correct 11 ms 12160 KB Output is correct
3 Correct 12 ms 12160 KB Output is correct
4 Correct 18 ms 12288 KB Output is correct
5 Correct 18 ms 12160 KB Output is correct
6 Correct 15 ms 12288 KB Output is correct
7 Correct 21 ms 13032 KB Output is correct
8 Correct 13 ms 12288 KB Output is correct
9 Correct 66 ms 17664 KB Output is correct
10 Correct 15 ms 12160 KB Output is correct
11 Correct 16 ms 12288 KB Output is correct
12 Correct 71 ms 18040 KB Output is correct
13 Correct 91 ms 20468 KB Output is correct
14 Correct 149 ms 17528 KB Output is correct
15 Correct 167 ms 18796 KB Output is correct
16 Correct 104 ms 20468 KB Output is correct
17 Correct 179 ms 16420 KB Output is correct
18 Correct 146 ms 18680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 13 ms 12160 KB Output is correct
3 Correct 11 ms 12032 KB Output is correct
4 Correct 18 ms 12288 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
6 Correct 14 ms 12288 KB Output is correct
7 Correct 20 ms 13056 KB Output is correct
8 Correct 13 ms 12288 KB Output is correct
9 Correct 63 ms 17632 KB Output is correct
10 Correct 15 ms 12160 KB Output is correct
11 Correct 13 ms 12288 KB Output is correct
12 Correct 70 ms 18040 KB Output is correct
13 Correct 118 ms 20488 KB Output is correct
14 Correct 144 ms 17528 KB Output is correct
15 Correct 151 ms 18768 KB Output is correct
16 Correct 87 ms 20468 KB Output is correct
17 Correct 156 ms 16224 KB Output is correct
18 Correct 148 ms 18808 KB Output is correct
19 Execution timed out 549 ms 53696 KB Time limit exceeded
20 Halted 0 ms 0 KB -