Submission #107724

# Submission time Handle Problem Language Result Execution time Memory
107724 2019-04-25T14:44:53 Z patrikpavic2 Senior Postmen (BOI14_postmen) C++17
0 / 100
150 ms 262148 KB
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <map>

#define X first
#define Y second
#define PB push_back
#define P push

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef set < int > si;

const int N = 5e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int OFF = (1 << 18);
const int LOG = 20;
const double EPS = 1e-9;
const double PI = 3.1415926535;

int bio[N], n, m, nod[N];
stack < pii > v[N];
stack < int > st;
vector < vi > cik;
vi tura;

void euler(int x){
    for(;!v[x].empty();){
        if(bio[v[x].top().Y]){
            v[x].pop();continue;
        }
        bio[v[x].top().Y] = 1;
        int nxt = v[x].top().X;
        v[x].pop();
        euler(nxt);
    }
    tura.PB(x);
}

void rastavi(){
    memset(bio, 0, sizeof(bio));
    for(int i = 0;i < tura.size();i++){
        if(bio[tura[i]]){
            while(st.top() != tura[i]){
                printf("%d ", st.top());
                bio[st.top()]--;
                st.pop();
            }
            st.pop();
            printf("%d\n", tura[i]);
        }
        st.P(tura[i]);
        bio[tura[i]]++;
    }
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0;i < m;i++){
        int x, y; scanf("%d%d", &x, &y);
        v[x].P({y, i});
        v[y].P({x, i});
    }

    euler(1);

    //printf("X\n");

    rastavi();
    return 0;
}

Compilation message

postmen.cpp: In function 'void rastavi()':
postmen.cpp:55:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < tura.size();i++){
                   ~~^~~~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:71:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:73:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x, y; scanf("%d%d", &x, &y);
                   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 150 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 132 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -