답안 #295951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
295951 2020-09-10T06:33:53 Z Trickster 장난감 기차 (IOI17_train) C++14
컴파일 오류
0 ms 0 KB
#include "train.h"
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define N 5010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) int(a.size())
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;}

int n, m;
int vis[N];
vector <int> E[N], T[N];

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

    for(int i = 0; i < m; i++) E[u[i].pb(v[i]);

    for(int i = 0; i < n; i++) {
    	if(r[i] == 0) continue;

    	int ok = 0;
    	for(auto h: E[i]) if(i == h) ok = 1;

    	if(ok == 1 && a[i] == 1) Q.push(i), vis[i] = 1;
    }

    while(!Q.empty()) {
    	int nd = Q.front();
    	Q.pop();

    	A[nd] = 1;
    	for(auto i: T[nd]) {
    		if(vis[i] == 1) continue;

    		int ok = 1;
    		if(a[i] == 0) for(auto j: E[i]) if(i == j) ok = 0;

    		if(ok == 1) Q.push(i);
    	}
    }

    vector <int> ret;
    for(int i = 0; i < n; i++) ret.pb(A[i]);

    return ret;
}

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:18:12: error: request for member 'push_back' in 'u.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 | #define pb push_back
      |            ^~~~~~~~~
train.cpp:35:39: note: in expansion of macro 'pb'
   35 |     for(int i = 0; i < m; i++) E[u[i].pb(v[i]);
      |                                       ^~
train.cpp:35:47: error: expected ']' before ';' token
   35 |     for(int i = 0; i < m; i++) E[u[i].pb(v[i]);
      |                                               ^
      |                                               ]
train.cpp:43:31: error: 'Q' was not declared in this scope
   43 |      if(ok == 1 && a[i] == 1) Q.push(i), vis[i] = 1;
      |                               ^
train.cpp:46:12: error: 'Q' was not declared in this scope
   46 |     while(!Q.empty()) {
      |            ^
train.cpp:50:6: error: 'A' was not declared in this scope
   50 |      A[nd] = 1;
      |      ^
train.cpp:62:39: error: 'A' was not declared in this scope
   62 |     for(int i = 0; i < n; i++) ret.pb(A[i]);
      |                                       ^