Submission #107731

# Submission time Handle Problem Language Result Execution time Memory
107731 2019-04-25T15:01:23 Z patrikpavic2 Senior Postmen (BOI14_postmen) C++17
0 / 100
143 ms 262148 KB
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <stack>
#include <set>
#include <vector>
#include <iostream>
#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;
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]]){
            if(st.empty()){
                printf("PUSI KURAC EULER\n");
                return;
            }
            while(st.top() != tura[i]){
                printf("%d ", st.top());
                bio[st.top()]--;
                st.pop();
                if(st.empty()){
                    printf("PUSI KURAC EULER\n");
                    return;
                }
            }
            st.pop();
            bio[tura[i]]--;
            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);
    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:80: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:82: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 136 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 134 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 143 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -