Submission #107738

# Submission time Handle Problem Language Result Execution time Memory
107738 2019-04-25T15:18:19 Z patrikpavic2 Senior Postmen (BOI14_postmen) C++17
0 / 100
16 ms 14080 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 + 5;
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],ind[N], rek[N], cur;
vector < pii > v[N];
vector < int > st;
vi tura;

void euler(){
    rek[cur++] = 1;
    for(;cur;){
        int x = rek[cur - 1];
        for(;ind[x] < v[x].size() && bio[v[x][ind[x]].Y];ind[x]++);
        if(ind[x] == v[x].size()) cur--;
        for(;ind[x] < v[x].size();ind[x]++){
            if(bio[v[x][ind[x]].Y]) continue;
            bio[v[x][ind[x]].Y] = 1;
            int nxt = v[x][ind[x]].X;
            rek[cur++] = nxt;
            break;
        }
        tura.PB(x);
    }
}

void rastavi(){
    memset(bio, 0, sizeof(bio));
    for(int i = 0;i < tura.size();i++){
        if(bio[tura[i]]){
            while(st.back() != tura[i]){
                printf("%d ", st.back());
                bio[st.back()]--;
                st.pop_back();
            }
            st.pop_back();
            bio[tura[i]]--;
            printf("%d\n", tura[i]);
        }
        st.PB(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].PB({y, i});
        v[y].PB({x, i});
    }
    euler();
    rastavi();
    return 0;
}

Compilation message

postmen.cpp: In function 'void euler()':
postmen.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(;ind[x] < v[x].size() && bio[v[x][ind[x]].Y];ind[x]++);
              ~~~~~~~^~~~~~~~~~~~~
postmen.cpp:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ind[x] == v[x].size()) cur--;
            ~~~~~~~^~~~~~~~~~~~~~
postmen.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(;ind[x] < v[x].size();ind[x]++){
              ~~~~~~~^~~~~~~~~~~~~
postmen.cpp: In function 'void rastavi()':
postmen.cpp:59: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:76: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:78: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 Incorrect 16 ms 14080 KB Edge does not exist or used 3, 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 14080 KB Edge does not exist or used 3, 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 14000 KB Edge does not exist or used 3, 2
2 Halted 0 ms 0 KB -