Submission #1110164

# Submission time Handle Problem Language Result Execution time Memory
1110164 2024-11-09T00:53:21 Z thunopro Board Game (JOI24_boardgame) C++14
0 / 100
15 ms 8784 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 [f[1]] = 0 ; 
	S . push ({1,d[f[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] << "\n" ; 
}
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) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 8784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7504 KB Output isn't correct
2 Halted 0 ms 0 KB -