답안 #427445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427445 2021-06-14T15:22:05 Z TLP39 장난감 기차 (IOI17_train) C++14
23 / 100
456 ms 32512 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(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(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: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: 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++)
      |                    ~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1072 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 11176 KB Output is correct
2 Correct 203 ms 18612 KB Output is correct
3 Correct 252 ms 22344 KB Output is correct
4 Correct 433 ms 30624 KB Output is correct
5 Correct 124 ms 7108 KB Output is correct
6 Correct 27 ms 2608 KB Output is correct
7 Correct 456 ms 32024 KB Output is correct
8 Correct 11 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 12 ms 1484 KB Output is correct
11 Correct 10 ms 1356 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 8 ms 1484 KB Output is correct
14 Correct 8 ms 1484 KB Output is correct
15 Correct 8 ms 1484 KB Output is correct
16 Correct 8 ms 1452 KB Output is correct
17 Correct 8 ms 1484 KB Output is correct
18 Correct 339 ms 32512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1448 KB Output is correct
2 Correct 9 ms 1492 KB Output is correct
3 Correct 8 ms 1460 KB Output is correct
4 Correct 10 ms 1336 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 6 ms 972 KB Output is correct
7 Correct 5 ms 1100 KB Output is correct
8 Correct 5 ms 1100 KB Output is correct
9 Correct 5 ms 1100 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 5 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1072 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -