답안 #757654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757654 2023-06-13T14:07:22 Z Rafi22 장난감 기차 (IOI17_train) C++14
5 / 100
7 ms 748 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);
    vector<int>q(n,0);
    for(int i=0;i<m;i++)
    {
        if(U[i]==V[i]) p[U[i]]=1;
        else q[U[i]]=1;
    }
    for(int i=n-1;i>=0;i--)
    {
        if(q[i]) DP[i]=DP[i+1];
        else DP[i]=r[i];
        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:101:4: warning: "/*" within comment [-Wcomment]
  101 |    /* int n,m;
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 624 KB Output is correct
5 Correct 5 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 568 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
# 결과 실행 시간 메모리 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 5 ms 748 KB Output is correct
2 Correct 7 ms 724 KB Output is correct
3 Correct 6 ms 724 KB Output is correct
4 Incorrect 6 ms 724 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 596 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 724 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 624 KB Output is correct
5 Correct 5 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 568 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Incorrect 1 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -