답안 #980082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980082 2024-05-11T22:24:29 Z hyakup 장난감 기차 (IOI17_train) C++17
23 / 100
1455 ms 100068 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

const int maxn = 5e3 + 10;
vector<int> adj[2][maxn], special, dono, marc( maxn );
int dp[maxn][maxn];

void solve( int cur ){
	for( int i = 0; i < marc.size(); i++ ) marc[i] = 0;
	queue<int> fila;
	for( int viz : adj[1][cur] ){
		if( dono[viz] ) fila.push(viz), dp[viz][cur] = 1;
		else{
			marc[viz]++;
			if( marc[viz] == adj[0][viz].size() ) fila.push(viz), dp[viz][cur] = 1;
		}
	}
	while( !fila.empty() ){
		int x = fila.front(); fila.pop();
		for( int viz : adj[1][x] ){
			if( dono[viz] ){ if( !dp[viz][cur] ) fila.push(viz), dp[viz][cur] = 1;}
			else{
				marc[viz]++;
				if( marc[viz] == adj[0][viz].size() ) fila.push(viz), dp[viz][cur] = 1;
			}
		}
	}
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
 	special = r; dono = a;
	int n = a.size();
	for( int i = 0; i < u.size(); i++ ){
		adj[0][u[i]].push_back(v[i]);
		adj[1][v[i]].push_back(u[i]);
	}
	for( int i = 0; i < n; i++ ) solve(i);
	vector<int> resp;
	for( int i = 0; i < n; i++ ){
		resp.push_back(0);
		for( int j = 0; j < n; j++ ) if( special[j] && dp[i][j] && dp[j][j] ) resp[i] = 1;
	}
	return resp;
}

Compilation message

train.cpp: In function 'void solve(int)':
train.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for( int i = 0; i < marc.size(); i++ ) marc[i] = 0;
      |                  ~~^~~~~~~~~~~~~
train.cpp:16:18: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |    if( marc[viz] == adj[0][viz].size() ) fila.push(viz), dp[viz][cur] = 1;
train.cpp:25:19: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if( marc[viz] == adj[0][viz].size() ) fila.push(viz), dp[viz][cur] = 1;
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for( int i = 0; i < u.size(); i++ ){
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 98020 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 99668 KB Output is correct
2 Correct 405 ms 99780 KB Output is correct
3 Correct 433 ms 99696 KB Output is correct
4 Correct 1167 ms 99808 KB Output is correct
5 Correct 933 ms 99636 KB Output is correct
6 Correct 740 ms 100068 KB Output is correct
7 Correct 751 ms 99932 KB Output is correct
8 Correct 387 ms 99764 KB Output is correct
9 Correct 382 ms 99920 KB Output is correct
10 Correct 431 ms 99528 KB Output is correct
11 Correct 377 ms 99568 KB Output is correct
12 Correct 78 ms 86868 KB Output is correct
13 Correct 1368 ms 99988 KB Output is correct
14 Correct 1308 ms 99920 KB Output is correct
15 Correct 1369 ms 99752 KB Output is correct
16 Correct 1352 ms 99760 KB Output is correct
17 Correct 1310 ms 99952 KB Output is correct
18 Correct 509 ms 99384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 97884 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 43340 KB Output is correct
2 Correct 1455 ms 99792 KB Output is correct
3 Correct 759 ms 80436 KB Output is correct
4 Correct 1292 ms 99788 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 134 ms 98456 KB Output is correct
7 Correct 40 ms 11612 KB Output is correct
8 Correct 35 ms 11608 KB Output is correct
9 Correct 34 ms 11720 KB Output is correct
10 Correct 2 ms 2904 KB Output is correct
11 Correct 63 ms 10536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 98020 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -