Submission #295960

# Submission time Handle Problem Language Result Execution time Memory
295960 2020-09-10T06:38:01 Z Trickster Toy Train (IOI17_train) C++14
Compilation error
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 A[N];
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]), T[v[i]].pb(u[i]);

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

    	int ok = 0, ok2 = 1;
    	for(auto h: E[i]) {
    		if(i == h) ok = 1;
    		else ok2 = 0;
    	}

    	if(ok == 1 && (a[i] == 1 || ok2 == 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;

    		vis[i] = 1;
    		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:48:9: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
   48 |      if(ok == 1 && (a[i] == 1 || ok2 == 1) Q.push(i), vis[i] = 1;
      |         ^~
train.cpp:48:43: error: expected ';' before 'Q'
   48 |      if(ok == 1 && (a[i] == 1 || ok2 == 1) Q.push(i), vis[i] = 1;
      |                                           ^~
      |                                           ;
train.cpp:49:5: error: expected primary-expression before '}' token
   49 |     }
      |     ^
train.cpp:48:66: error: expected ')' before '}' token
   48 |      if(ok == 1 && (a[i] == 1 || ok2 == 1) Q.push(i), vis[i] = 1;
      |        ~                                                         ^
      |                                                                  )
   49 |     }
      |     ~                                                             
train.cpp:49:5: error: expected primary-expression before '}' token
   49 |     }
      |     ^