Submission #35652

# Submission time Handle Problem Language Result Execution time Memory
35652 2017-11-26T20:58:49 Z imaxblue Senior Postmen (BOI14_postmen) C++14
100 / 100
483 ms 69624 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 fox(k, x) for (int k=0; k<x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
 #define pc(x) putchar_unlocked(x);
    inline void out(int n)
    {
        int N = n, rev, count = 0;
        rev = N;
        if (N == 0) { pc('0'); pc('\n'); return ;}
        while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s
        rev = 0;
        while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}  //store reverse of N in rev
        while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
        while (count--) pc('0');
    }
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=vector<int>();
        while(t!=N){
            ans.pb(t=s.back()); s.pop_back();
            u[t]=0;
        }
        fox(l, ans.size()){
            out(ans[l]);
            if (l!=ans.size()-1) putchar_unlocked(' ');
        } putchar_unlocked('\n');
    }
    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;
            dfs(v[N][p[N]].x);
        }
    }
}
int main(){
    scan(n); scan(m);
    fox(l, m){
        scan(a); scan(b);
        v[a].pb(mp(b, l));
        v[b].pb(mp(a, l));
    }
    dfs(1);
    return 0;
}

Compilation message

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:9:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
postmen.cpp:37:13:
         fox(l, ans.size()){
             ~~~~~~~~~~~~~         
postmen.cpp:37:9: note: in expansion of macro 'fox'
         fox(l, ans.size()){
         ^~~
postmen.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (l!=ans.size()-1) putchar_unlocked(' ');
                 ~^~~~~~~~~~~~~~
postmen.cpp:42:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(; p[N]<v[N].size(); ++p[N]){
           ~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12136 KB Output is correct
2 Correct 12 ms 12160 KB Output is correct
3 Correct 11 ms 12032 KB Output is correct
4 Correct 12 ms 12416 KB Output is correct
5 Correct 12 ms 12228 KB Output is correct
6 Correct 12 ms 12416 KB Output is correct
7 Correct 17 ms 13568 KB Output is correct
8 Correct 12 ms 12264 KB Output is correct
9 Correct 36 ms 20780 KB Output is correct
10 Correct 13 ms 12160 KB Output is correct
11 Correct 13 ms 12288 KB Output is correct
12 Correct 42 ms 21072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12032 KB Output is correct
2 Correct 12 ms 12148 KB Output is correct
3 Correct 12 ms 12160 KB Output is correct
4 Correct 13 ms 12416 KB Output is correct
5 Correct 12 ms 12136 KB Output is correct
6 Correct 12 ms 12544 KB Output is correct
7 Correct 17 ms 13568 KB Output is correct
8 Correct 11 ms 12288 KB Output is correct
9 Correct 38 ms 20704 KB Output is correct
10 Correct 13 ms 12288 KB Output is correct
11 Correct 12 ms 12288 KB Output is correct
12 Correct 42 ms 21112 KB Output is correct
13 Correct 80 ms 23588 KB Output is correct
14 Correct 70 ms 19104 KB Output is correct
15 Correct 79 ms 21864 KB Output is correct
16 Correct 78 ms 23644 KB Output is correct
17 Correct 80 ms 16600 KB Output is correct
18 Correct 94 ms 21012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12032 KB Output is correct
2 Correct 15 ms 12032 KB Output is correct
3 Correct 14 ms 12016 KB Output is correct
4 Correct 12 ms 12392 KB Output is correct
5 Correct 11 ms 12160 KB Output is correct
6 Correct 13 ms 12416 KB Output is correct
7 Correct 16 ms 13616 KB Output is correct
8 Correct 14 ms 12288 KB Output is correct
9 Correct 36 ms 20700 KB Output is correct
10 Correct 15 ms 12288 KB Output is correct
11 Correct 12 ms 12288 KB Output is correct
12 Correct 63 ms 21088 KB Output is correct
13 Correct 69 ms 23516 KB Output is correct
14 Correct 68 ms 19064 KB Output is correct
15 Correct 64 ms 21864 KB Output is correct
16 Correct 82 ms 23540 KB Output is correct
17 Correct 77 ms 16632 KB Output is correct
18 Correct 82 ms 21012 KB Output is correct
19 Correct 470 ms 69624 KB Output is correct
20 Correct 425 ms 47712 KB Output is correct
21 Correct 397 ms 61148 KB Output is correct
22 Correct 459 ms 69456 KB Output is correct
23 Correct 154 ms 54496 KB Output is correct
24 Correct 483 ms 34040 KB Output is correct
25 Correct 462 ms 57332 KB Output is correct