Rezultati

Up. imeNalogaJezikRezultatČas oddaje
pokosimo-2018 Dolenjec C++ 100/100OK 10. maj '18 @ 19:59

Test Točke Porabljen spomin Porabljen čas Status
#1 3/3 3,160 MiB 0,000 s OK
#2 3/3 3,160 MiB 0,004 s OK
#3 3/3 3,223 MiB 0,004 s OK
#4 3/3 3,230 MiB 0,004 s OK
#5 3/3 3,227 MiB 0,004 s OK
#6 3/3 3,160 MiB 0,000 s OK
#7 3/3 3,156 MiB 0,004 s OK
#8 3/3 3,156 MiB 0,004 s OK
#9 3/3 3,152 MiB 0,004 s OK
#10 3/3 3,160 MiB 0,004 s OK
#11 3/3 3,160 MiB 0,004 s OK
#12 3/3 3,160 MiB 0,004 s OK
#13 3/3 3,160 MiB 0,004 s OK
#14 3/3 3,164 MiB 0,000 s OK
#15 3/3 3,230 MiB 0,004 s OK
#16 3/3 3,160 MiB 0,004 s OK
#17 3/3 3,234 MiB 0,000 s OK
#18 3/3 3,254 MiB 0,004 s OK
#19 3/3 3,250 MiB 0,004 s OK
#20 3/3 3,180 MiB 0,004 s OK
#21 3/3 3,180 MiB 0,004 s OK
#22 3/3 3,336 MiB 0,000 s OK
#23 3/3 9,309 MiB 0,164 s OK
#24 3/3 8,672 MiB 0,133 s OK
#25 3/3 8,566 MiB 0,122 s OK
#26 3/3 5,699 MiB 0,093 s OK
#27 3/3 4,973 MiB 0,093 s OK
#28 3/3 8,926 MiB 0,122 s OK
#29 3/3 8,504 MiB 0,091 s OK
#30 3/3 5,773 MiB 0,087 s OK
#31 3/3 4,898 MiB 0,093 s OK
#32 3/3 4,258 MiB 0,075 s OK
#33 4/4 3,230 MiB 0,004 s OK

Ocenjevani program (dolenc.cpp):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

//vector<bool> gostilna

int main() {
    int n, m, d, q;
    scanf("%d %d %d %d", &n, &m, &d, &q);
    vector<bool> gostilna(n+1, false);
    for(int i=0; i<d; ++i) {
        int a;
        scanf("%d", &a);
        gostilna[a] = true;
    }
    vector< vector<int> > graf(n+1, vector<int>());
    for(int i=0; i<m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        graf[a].push_back(b);
    }
    vector<bool> obiskani(n+1, false);
    vector<int> stack, pot, count;
    count.push_back(1);
    stack.push_back(q);
    while(stack.size() > 0) {
        int zdej = stack[stack.size()-1]; 
        stack.pop_back();
        // tuki morva odstet od tega stringa
        while(count[count.size()-1] == 0) {
            count.pop_back();
            obiskani[pot[pot.size()-1]] = false;
            pot.pop_back();
        }
        count[count.size()-1]--;
        // mogoce sporno!
        pot.push_back(zdej);
        if(obiskani[zdej]) {
            for(int i = pot.size() -2; i>=0; i--) {
                if(gostilna[pot[i]]) {
                    cout << "DA" << endl;
                    return 0;
                }
                if(pot[i] == zdej) break;
            }
            pot.pop_back();
            continue;
        }
        else {
            obiskani[zdej] = true;
            count.push_back(graf[zdej].size());
            for(int i=0; i<graf[zdej].size(); ++i) {
                stack.push_back(graf[zdej][i]);
            }
        }
    }
    cout << "NE" << endl;
    return 0;
}