답안 #577645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577645 2022-06-15T07:21:19 Z Theo830 장난감 기차 (IOI17_train) C++17
0 / 100
76 ms 1264 KB
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define ull unsigned int
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "train.h"
bool ok[5005];
bool v[5005];
bool res[5005];
bool ans[5005];
vector<vll>adj;
vector<int> A;
bool solve(ll x,ll s){
    v[x] = 1;
    ans[x] = A[x] ^ 1;
    for(auto X:adj[x]){
        if(!v[X]){
            if(A[x] == 1){
                ans[x] |= solve(X,s);
            }
            else{
                ans[x] &= solve(X,s);
            }
        }
        else if(X == s){
            if(A[x] == 1){
                ans[x] |= 1;
            }
            else{
                ans[x] &= 1;
            }
        }
        else{
            if(A[x] == 1){
                ans[x] |= ans[X];
            }
            else{
                ans[x] &= ans[X];
            }
        }
    }
    return ans[x];
}
bool kame(ll x){
    v[x] = 1;
    ans[x] = A[x] ^ 1;
    if(A[x] == ok[x] && ok[x] == 1){
        ans[x] = 1;
    }
    for(auto X:adj[x]){
        if(A[x] == 1){
            ans[x] |= ok[X];
        }
        else{
            ans[x] &= ok[X];
        }
        if(!v[X]){
            kame(X);
        }
        else{
            if(A[x] == 1){
                ans[x] |= ans[X];
            }
            else{
                ans[x] &= ans[X];
            }
        }
    }
    return ans[x];
}
vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
    vector<int> res(a.size());
    ll n = a.size();
    ll m = u.size();
    A = a;
    adj.assign(n+5,vll());
    f(i,0,m){
        adj[u[i]].pb(v[i]);
    }
    f(i,0,n){
        if(r[i] == 1){
            f(j,0,n+5){
                v[j] = 0;
                ans[j] = 0;
            }
            ok[i] = solve(i,i);
        }
    }
    f(i,0,n){
        f(j,0,n+5){
            v[j] = 0;
            ans[j] = 0;
        }
        res[i] = kame(i);
    }
    return res;
}
/*
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;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 1236 KB Output is correct
2 Correct 48 ms 1108 KB Output is correct
3 Correct 54 ms 1224 KB Output is correct
4 Incorrect 55 ms 1264 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 1108 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 1236 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -