Submission #283827

# Submission time Handle Problem Language Result Execution time Memory
283827 2020-08-26T07:41:35 Z mohammad Toy Train (IOI17_train) C++14
Compilation error
0 ms 0 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
 
#define endl "\n"
// #define int long long

typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7  ;
const int N = 10000010  ;

vector<int> g[5010] , w , R;

int dfs(int i){
	if(w[i] != -1)  return w[i];
	for(auto x : g[i])
		w[i] = dfs(x);
	if(w[i] == -1) w[i] = R[i];
	return w[i] ;
}

int root[150010];

ll find(int u){
	if(root[u] == u)
		return u ;
	return root[u] = find(root[u]);
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size() , m = u.size();
	w = vector<int>(n , 0);
	R = r;
	for(int i = 0; i < n ; ++i) root[i] = i ;
	for(int i = 0 ; i < m ; ++i){
		int x = u[i] , y = v[i];
		root[find(x)] = find(y);
		// if(x == y && a[x] == 1 && r[x] == 1) w[x] = 1;
		// if(x == y && a[x] == 0 && r[x] == 0) w[x] = 0;
		// else if(x != y) g[x].push_back(y);
	}
	f#include "train.h"
#include<bits/stdc++.h>
using namespace std;
 
#define endl "\n"
// #define int long long

typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7  ;
const int N = 10000010  ;

vector<int> g[5010] , w , R;

int dfs(int i){
	if(w[i] != -1)  return w[i];
	for(auto x : g[i])
		w[i] = dfs(x);
	if(w[i] == -1) w[i] = R[i];
	return w[i] ;
}

int root[150010];

ll find(int u){
	if(root[u] == u)
		return u ;
	return root[u] = find(root[u]);
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size() , m = u.size();
	w = vector<int>(n , 0);
	R = r;
	for(int i = 0; i < n ; ++i) root[i] = i ;
	for(int i = 0 ; i < m ; ++i){
		int x = u[i] , y = v[i];
		root[find(x)] = find(y);
		// if(x == y && a[x] == 1 && r[x] == 1) w[x] = 1;
		// if(x == y && a[x] == 0 && r[x] == 0) w[x] = 0;
		// else if(x != y) g[x].push_back(y);
	}
	for(int i = 0 ; i < n ; ++i){
		find(i);
		if(r[i] == 1) w[root[i]] = 1;
	}
	for(int i = 0 ; i < n ; ++i) w[i] = w[root[i]];
	// for(int i = 0 ; i < n ; ++i){
	// 	if(w[i] != -1) continue ;
	// 	dfs(i);
	// }
	return w;
}
or(int i = 0 ; i < n ; ++i){
		find(i);
		if(r[i] == 1) w[root[i]] = 1;
	}
	for(int i = 0 ; i < n ; ++i) w[i] = w[root[i]];
	// for(int i = 0 ; i < n ; ++i){
	// 	if(w[i] != -1) continue ;
	// 	dfs(i);
	// }
	return w;
}

Compilation message

train.cpp:46:3: error: stray '#' in program
   46 |  f#include "train.h"
      |   ^
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:46:2: error: 'f' was not declared in this scope
   46 |  f#include "train.h"
      |  ^
train.cpp:62:15: error: a function-definition is not allowed here before '{' token
   62 | int dfs(int i){
      |               ^
train.cpp:72:15: error: a function-definition is not allowed here before '{' token
   72 | ll find(int u){
      |               ^
train.cpp:79:82: error: a function-definition is not allowed here before '{' token
   79 | vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
      |                                                                                  ^
train.cpp:102:1: error: expected primary-expression before 'or' token
  102 | or(int i = 0 ; i < n ; ++i){
      | ^~
train.cpp:102:4: error: expected primary-expression before 'int'
  102 | or(int i = 0 ; i < n ; ++i){
      |    ^~~
train.cpp:102:4: error: expected ')' before 'int'
  102 | or(int i = 0 ; i < n ; ++i){
      |   ~^~~
      |    )
train.cpp:102:16: error: 'i' was not declared in this scope
  102 | or(int i = 0 ; i < n ; ++i){
      |                ^
train.cpp:54:10: warning: unused variable 'ooo' [-Wunused-variable]
   54 | const ll ooo = 1e14 ;
      |          ^~~
train.cpp:55:10: warning: unused variable 'oo' [-Wunused-variable]
   55 | const ll oo = 2e9 ;
      |          ^~
train.cpp:56:14: warning: unused variable 'PI' [-Wunused-variable]
   56 | const double PI = acos(-1) ;
      |              ^~
train.cpp:57:10: warning: unused variable 'M' [-Wunused-variable]
   57 | const ll M = 1e9 + 7  ;
      |          ^
train.cpp:58:11: warning: unused variable 'N' [-Wunused-variable]
   58 | const int N = 10000010  ;
      |           ^