답안 #617657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617657 2022-08-01T12:39:32 Z Sergio_2357 장난감 기차 (IOI17_train) C++17
5 / 100
9 ms 1124 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef vector<int> vi;

vector<signed> who_wins(vector<signed> a, vector<signed> r, vector<signed> u, vector<signed> v)
{
    vector<signed> res(a.size(), 0);
    vi ws, ls;
    set<int> brk;
    for (int i = 0; i < a.size(); i++)
        brk.insert(i);
    for (int i = 0; i < u.size(); i++) {
        if (u[i] == v[i]) {
            if (r[u[i]] && a[u[i]])
                ws.push_back(u[i]);
            if (!r[u[i]] && !a[u[i]])
                ls.push_back(u[i]);
        } else {
            brk.erase(u[i]);
        }
    }
    sort(ws.begin(), ws.end());
    sort(ls.begin(), ls.end());
    for (int i = 0; i < a.size(); i++) {
        auto wit = lower_bound(ws.begin(), ws.end(), i);
        auto lit = lower_bound(ls.begin(), ls.end(), i);
        auto l2it = brk.lower_bound(i);
        int nw = (wit != ws.end() ? *wit : INT_MAX);
        int nl = (lit != ls.end() ? *lit : INT_MAX);
        int nl2 = (l2it != brk.end() ? *l2it : INT_MAX);
        if (nw < nl && nw <= nl2 || (nl > nl2 && r[nl2]))
            res[i] = 1;
    }
    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:15:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
train.cpp:17:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < u.size(); i++) {
      |                     ~~^~~~~~~~~~
train.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
train.cpp:36:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   36 |         if (nw < nl && nw <= nl2 || (nl > nl2 && r[nl2]))
      |             ~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 724 KB Output is correct
2 Correct 4 ms 732 KB Output is correct
3 Correct 5 ms 724 KB Output is correct
4 Correct 5 ms 724 KB Output is correct
5 Correct 4 ms 824 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 4 ms 824 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 4 ms 720 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
# 결과 실행 시간 메모리 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 9 ms 1084 KB Output is correct
2 Correct 7 ms 1108 KB Output is correct
3 Correct 6 ms 1108 KB Output is correct
4 Incorrect 7 ms 1124 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 980 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1108 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 724 KB Output is correct
2 Correct 4 ms 732 KB Output is correct
3 Correct 5 ms 724 KB Output is correct
4 Correct 5 ms 724 KB Output is correct
5 Correct 4 ms 824 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 4 ms 824 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 4 ms 720 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
12 Incorrect 0 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -