답안 #757649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757649 2023-06-13T14:03:54 Z Rafi22 장난감 기차 (IOI17_train) C++14
0 / 100
9 ms 852 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=5007;
/*
int a[N],r[N];
vector<int>G[N];
vector<int>RG[N];
int ile[N];
bool is[N];

vector<int> who_wins(vector<int>a,vector<int>r,vector<int>U,vector<int>V)
{
    int n=sz(a),m=sz(U);
    vector<int>ans(n,1);
    for(int i=0;i<m;i++)
    {
        G[U[i]].pb(V[i]);
        RG[V[i]].pb(U[i]);
    }
    while(true)
    {
        memset(ile,0,sizeof ile);
        deque<int>Q;
        for(int i=0;i<n;i++) if(r[i]) Q.pb(i);
        while(sz(Q)>0)
        {
            int v=Q[0];
            Q.pop_front();
            for(auto u:RG[v])
            {
                if(is[u]) continue;
                ile[u]++;
                if(a[u]==1||ile[u]==sz(G[u]))
                {
                    is[u]=1;
                    Q.pb(u);
                }
            }
        }
        bool xd=0;
        for(int i=0;i<n;i++) if(!is[i]) ans[i]=0;
        for(int i=0;i<n;i++)
        {
            if(!r[i]) continue;
            int c=0;
            for(auto u:G[i]) if(is[u]) c++;
            if(c==0||(a[i]==0&&c!=sz(G[i])))
            {
                r[i]=0;
                xd=1;
                break;
            }
        }
        if(!xd) break;
    }
    return ans;
}*/

vector<int> who_wins(vector<int>a,vector<int>r,vector<int>U,vector<int>V)
{
    int n=sz(a),m=sz(U);
    vector<int>DP(n,0);
    vector<int>p(n,0);
    for(int i=0;i<m;i++)
    {
        if(U[i]==V[i]) p[U[i]]=1;
    }
    DP[n-1]=r[n-1];
    for(int i=n-2;i>=0;i--)
    {
        DP[i]=DP[i+1];
        if(p[i])
        {
            if(a[i]==0&&r[i]==0) DP[i]=0;
            if(a[i]==1&&r[i]==1) DP[i]=1;
        }
    }
    return DP;
}
/*
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* int n,m;
    cin>>n>>m;
    vector<int>a,r;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>r[i];
    vector<int>x=who_wins({0, 1},{1, 0},{0, 0, 1, 1},{0, 1, 0, 1});
    for(auto a:x) cout<<a<<" ";

    return 0;
}*/

Compilation message

train.cpp:99:4: warning: "/*" within comment [-Wcomment]
   99 |    /* int n,m;
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Output is correct
2 Correct 3 ms 568 KB Output is correct
3 Incorrect 5 ms 596 KB 3rd lines differ - on the 355th token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 6 ms 828 KB Output is correct
3 Correct 5 ms 852 KB Output is correct
4 Incorrect 9 ms 820 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 576 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 612 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Output is correct
2 Correct 3 ms 568 KB Output is correct
3 Incorrect 5 ms 596 KB 3rd lines differ - on the 355th token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -