QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#206952 | #7558. Abstract | ucup-team197# | WA | 0ms | 3864kb | C++17 | 1.5kb | 2023-10-08 00:47:16 | 2023-10-08 00:47:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
typedef vector < int > vi ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
const int MOD = 998244353 ;
const int MAXN = 1e4 + 7 ;
int n , m ;
vector < int > v[ MAXN ] ;
ll a[ MAXN ] , b[ MAXN ] ;
void solve ( ) {
cin >> n >> m ;
for ( int i = 1 ; i <= n ; ++ i ) {
cin >> a[ i ] ;
}
for ( int i = 1 , x , y ; i <= m ; ++ i ) {
cin >> x >> y ;
v[ x ].push_back ( y ) ;
}
int ans = 0 ;
while ( 1 ) {
bool done = true ;
for ( int i = 1 ; i <= n ; ++ i ) {
if ( a[ i ] > 0 ) {
done = false ;
break ;
}
}
for ( int i = 1 ; i <= n ; ++ i ) {
b[ i ] = a[ i ] ;
a[ i ] = 0 ;
}
if ( done == true ) { break ; }
++ ans ;
for ( int i = 1 ; i <= n ; ++ i ) {
for ( auto j : v[ i ] ) {
a[ j ] += b[ i ] ;
}
a[ i ] += b[ i ] / 2 ;
}
}
cout << ans << "\n" ;
}
int main ( ) {
ios_base :: sync_with_stdio ( false ) ;
cin.tie ( NULL ) ;
int t = 1 ; // cin >> t ;
while ( t -- ) { solve ( ) ; }
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
input:
3 2 1 1 1 1 2 2 3
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3864kb
input:
6 8 1 1 4 5 1 4 1 4 1 5 2 3 2 5 3 4 4 5 4 6 5 6
output:
12
result:
wrong answer 1st numbers differ - expected: '8', found: '12'