Submission #1240139

#TimeUsernameProblemLanguageResultExecution timeMemory
1240139Zbyszek99Toy Train (IOI17_train)C++20
Compilation error
0 ms0 KiB
#include "train.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<long long>
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
//mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll rand(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;

vi ans;
vi graph_in[5001];
vi graph_out[5001];
bool is_bat[5001];
bool odw[5001];
bool type[5001];
int cnt[5001];

bool solve(int n)
{
	queue<int> q;
	rep(i,n)
	{
		ans[i] = 0;
		if(type[i] == 0) cnt[i] = siz(graph_out[i]);
		odw[i] = 0;
		bool was = 0;
		forall(it,graph_out[i])
		{
			if(is_bat[it]) was = 1;
		}
		if(was) q.push(i);
	}
	while(!q.empty())
	{
		int t = q.front();
		q.pop();
		if(odw[t]) continue;
		odw[t]++;
		ans[t] = 1;
		forall(it,graph_in[t])
		{
			if(type[it] == 1)
			{
				q.push(it);
			}
			else
			{
				cnt[it]--;
				if(cnt[it] == 0) q.push(it);
			}
		}
	}
	rep(i,n)
	{
		if(is_bat[i] && ans[i] == 0) return 0;
	}
	return 1;
}

vi who_wins(vi a, vi r, vi u, vi v) 
{
	int n = siz(a);
	ans.resize(n);
	rep(i,n) is_bat[i] = r[i];
	rep(i,n) type[i] = a[i];
	rep(i,siz(u))
	{
		graph_out[u[i]].pb(v[i]);
		graph_in[v[i]].pb(u[i]);
	}
	while(!solve(n));
	return ans;
}

Compilation message (stderr)

train.cpp: In function 'bool solve(int)':
train.cpp:54:22: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   54 |                 odw[t]++;
      |                 ~~~~~^