답안 #747015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747015 2023-05-23T12:05:47 Z danikoynov 장난감 기차 (IOI17_train) C++14
0 / 100
12 ms 1084 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 5010;
int n, m, a[maxn], r[maxn], cycle[maxn], nxt[maxn];
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V)
{
    n = A.size();
    m = U.size();
    for (int i = 0; i < n; i ++)
        a[i] = A[i];
    for (int i = 0; i < n; i ++)
        r[i] = R[i];

    for (int i = 0; i < m; i ++)
    {
        if (U[i] == V[i])
        {
            cycle[U[i]] = 1;
            ///cout << "HERE" << endl;
        }
        else
        {
            nxt[U[i]] = 1;
        }
    }

    vector < int > res(n, 0);
    for (int i = 0; i < n; i ++)
    {
        int fn = - 1, dn = -1;
        int j = i;
        while(true)
        {
            ///cout << i << " : " << j << endl;
            if (cycle[j])
            {
                //cout << "here" << endl;
                if (a[j] == 1)
                {
                    if (r[j])
                    {
                        res[i] = 1;
                        break;
                    }
                }
                else
                    break;
            }
            if (nxt[j])
            {
                j ++;
            }
            else
            {
                break;
            }
        }
    }

    return res;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:33:13: warning: unused variable 'fn' [-Wunused-variable]
   33 |         int fn = - 1, dn = -1;
      |             ^~
train.cpp:33:23: warning: unused variable 'dn' [-Wunused-variable]
   33 |         int fn = - 1, dn = -1;
      |                       ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 596 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 308 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1084 KB Output is correct
2 Correct 11 ms 980 KB Output is correct
3 Correct 11 ms 984 KB Output is correct
4 Incorrect 11 ms 980 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 828 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1000 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 596 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -