답안 #429291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
429291 2021-06-15T20:04:25 Z Dremix10 장난감 기차 (IOI17_train) C++17
0 / 100
10 ms 1484 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<", "<<#y<<" = {"<<x<<", "<<y<<"}"<<endl;
    #define pp(x) cerr<<#x<<" = "<<"("<<x.F<<" - "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y.F<<"-"<<y.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-9;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 5001;

vector<vector<int> > adj(N);

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    int n = a.size();
    int m = u.size();

    int i,j;


    for(i=0;i<m;i++){
        int x = u[i];
        int y = v[i];
        assert(x<=y);
        adj[x].push_back(y);
    }

    vector<int> ans(n);

    for(i=0;i<n;i++){
        bool self = false;
        bool nxt = false;
        for(auto x : adj[i])
            if(x==i)self = true;
            else nxt = true;
        bool win = false;

        if(a[i] && self && r[i])
            win = true;
        if(i>0 && a[i] && ans[i-1] && nxt)
            win = true;
        if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
            win = true;
        ans[i] = win;
    }

    return ans;
/*

g++ grader.cpp trainSub.cpp -Ddremix

*/

}

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:63:27: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   63 |         if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
train.cpp:63:67: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   63 |         if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
train.cpp:39:11: warning: unused variable 'j' [-Wunused-variable]
   39 |     int i,j;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 716 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 1440 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 1228 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 1484 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 716 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -