Submission #427443

# Submission time Handle Problem Language Result Execution time Memory
427443 2021-06-14T15:20:31 Z TLP39 Toy Train (IOI17_train) C++14
Compilation error
0 ms 0 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;

int n,m;
vector<int> point_to[5003];
int ori_outdeg[5003]={};
int temp_outdeg[5003];

vector<int> res_graph[5003];
int graph_outdeg[5003]={};

void getreach(int v)
{
  	queue<int> q;
  	int tt;
  	for(int i=0;i<n;i++) temp_outdeg[i]=ori_outdeg[i];
  	for(int i=0;i<point_to[v].size();i++)
    {
      	temp_outdeg[point_to[v][i]]--;
      	if(!temp_outdeg[point_to[v][i]]) q.push_back(point_to[v][i]);
    }
  	while(!q.empty())
    {
      	tt=q.front();
      	q.pop();
      	res_graph[v].push_back(tt);
      	graph_outdeg[tt]++;
      	if(tt==v) continue;
      	for(int i=0;i<point_to[tt].size();i++)
    	{
      		temp_outdeg[point_to[tt][i]]--;
      		if(!temp_outdeg[point_to[tt][i]]) q.push_back(point_to[tt][i]);
    	}
    }
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	std::vector<int> res(a.size(),1);
  	n=a.size();
  	m=u.size();
  	for(int i=0;i<m;i++) 
    {
      	point_to[v[i]].push_back(u[i]);
      	ori_outdeg[u[i]]++;
    }
  	for(int i=0;i<n;i++) if(a[i]) ori_outdeg[i]=1;
  	for(int i=0;i<n;i++)
    {
      	if(r[i]) getreach(i);
    }
  	queue<int> q;
  	for(int i=0;i<n;i++) if(!graph_outdeg[i]) q.push(i);
  	int fr;
  	while(!q.empty())
    {
      	fr=q.front();
      	q.pop();
      	res[fr]=0;
      	for(int i=0;i<res_graph[fr].size();i++)
        {
          	graph_outdeg[res_graph[fr][i]]--;
            if(!graph_outdeg[res_graph[fr][i]]) q.push(res_graph[fr][i]);
        }
    }
	return res;
}

Compilation message

train.cpp: In function 'void getreach(int)':
train.cpp:18:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |    for(int i=0;i<point_to[v].size();i++)
      |                ~^~~~~~~~~~~~~~~~~~~
train.cpp:21:43: error: 'class std::queue<int>' has no member named 'push_back'
   21 |        if(!temp_outdeg[point_to[v][i]]) q.push_back(point_to[v][i]);
      |                                           ^~~~~~~~~
train.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |        for(int i=0;i<point_to[tt].size();i++)
      |                    ~^~~~~~~~~~~~~~~~~~~~
train.cpp:33:45: error: 'class std::queue<int>' has no member named 'push_back'
   33 |         if(!temp_outdeg[point_to[tt][i]]) q.push_back(point_to[tt][i]);
      |                                             ^~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:60:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |        for(int i=0;i<res_graph[fr].size();i++)
      |                    ~^~~~~~~~~~~~~~~~~~~~~