답안 #1110162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110162 2024-11-09T00:47:15 Z thunopro Board Game (JOI24_boardgame) C++14
0 / 100
14 ms 9296 KB
#include<bits/stdc++.h>
using namespace std ; 
#define maxn 200009
#define ll long long 
#define pb push_back 
#define fi first 
#define se second 
#define left id<<1
#define right id<<1|1 
#define re exit(0); 
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1 
#define TIME ( 1.0*clock() / CLOCKS_PER_SEC )
const int mod = 1e9+7 ;
const int INF = 1e9 ; 

typedef vector<int> vi ; 
typedef pair<int,int> pii ; 
typedef vector<pii> vii ; 

template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; } 
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; } 

void add ( int &a , int b ) 
{
	a += b ; 
	if ( a >= mod ) a -= mod ; 
	if ( a < 0 ) a += mod ; 
}

void rf () 
{
	freopen ("bai1.inp","r",stdin) ;
}

mt19937 rng (time(0)) ; 

int _pow ( int a , int n ) 
{
	if ( n == 0 ) return 1 ; 
	int res = _pow (a,n/2) ; 
	if ( n % 2 ) return 1ll*res*res%mod*a%mod ; 
	else return 1ll*res*res%mod ; 
}

int n , m , k ; 
vi adjList [maxn] ; 
int f [maxn] ; 
int c [maxn] ; 

bool checksub1 () 
{
	int total = 0 ; 
	for ( int i = 1 ; i <= n ; i ++ ) total += c [i] ; 
	return (total == 0) ; 
}
int d [maxn] ; 
struct shape {
	int u , d ; 
	bool operator < ( const shape &o ) const 
	{
		return d > o.d ; 
	}
};
void sub1 () 
{
	priority_queue <shape> S ; 
	memset ( d , 0x3f , sizeof d ) ; 
	d [1] = 0 ; 
	S . push ({1,d[1]}) ; 
	while (!S.empty()) 
	{
		shape t = S.top() ; S.pop() ; 
		int u = t.u ; 
		if ( t.d != d [u] ) continue ; 
		for ( auto v : adjList [u] ) 
		{
			if ( d [v] > d [u] + 1 ) S.push ({v,d[v]=d[u]+1}) ; 
		}
	}
	for ( int i = 1 ; i <= n ; i ++ ) cout << d [i] << " " ; 
}
int main () 
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);cout.tie(0); 
//	rf () ;
	cin >> n >> m >> k ; 
	for ( int i = 1 ; i <= m ; i ++ ) 
	{
		int u , v ; cin >> u >> v ; 
		adjList [u] . pb (v) ; 
		adjList [v] . pb (u) ; 
	}
	
	for ( int i = 1 ; i <= n ; i ++ ) 
	{
		char x ; cin >> x ; 
		c [i] = x - '0' ; 
	}
	
	for ( int i = 1 ; i <= k ; i ++ ) cin >> f [i] ; 
	
	if ( checksub1 () ) sub1 () ; 
	

}

Compilation message

Main.cpp: In function 'void rf()':
Main.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen ("bai1.inp","r",stdin) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 7504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 9296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 9296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 7504 KB Output isn't correct
2 Halted 0 ms 0 KB -