Submission #592967

# Submission time Handle Problem Language Result Execution time Memory
592967 2022-07-10T00:52:31 Z perchuts Toy Train (IOI17_train) C++17
0 / 100
6 ms 1236 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;

const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 5005;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

vector<int>g[maxn];

int deg[maxn];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    int n = sz(a), m = sz(u);
    for(int i=0;i<m;++i){
        int x = u[i], y = v[i];
        g[y].pb(x);
    }
    vector<int>resp(n);
    queue<int>q;
    for(int i=0;i<n;++i){
        if(r[i]==1){
            q.push(i);
            resp[i] = 1;
        }
    }
    while(!q.empty()){
        int x = q.front(); q.pop();
        for(auto y:g[x]){
            ++deg[y];
            if(!resp[y]&&(a[y]==1||deg[y]==sz(g[y]))){
                resp[y] = 1;
                q.push(y);
            }
        }
    }
    return resp;
}

// int main() {
// 	int n, m;
// 	assert(2 == scanf("%d %d", &n, &m));

// 	vector<int> a(n), r(n), u(m), v(m);

// 	for(int i = 0; i < n; i++)
// 		assert(1 == scanf("%d", &a[i]));

// 	for(int i = 0; i < n; i++)
// 		assert(1 == scanf("%d", &r[i]));

// 	for(int i = 0; i < m; i++)
// 		assert(2 == scanf("%d %d", &u[i], &v[i]));

// 	vector<int> res = who_wins(a, r, u, v);

// 	for(int i = 0; i < (int)res.size(); i++)
// 		printf(i ? " %d" : "%d", res[i]);
// 	printf("\n");

// 	return 0;
// }
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1112 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1236 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -