답안 #922306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922306 2024-02-05T11:50:27 Z thunopro 돌 무게 재기 (IZhO11_stones) C++14
100 / 100
35 ms 7768 KB
#include<bits/stdc++.h>
using namespace std ; 
#define maxn 200009 
#define ll long long 
#define fi first 
#define se second 
#define pb push_back 
#define left id<<1
#define right id<<1|1 
#define re exit(0); 

const int mod = 1e9+7; 
const int INF = 1e9; 

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

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

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 ; }

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 ; 
}

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

int n ; 
pii T [maxn*4] ; 
int lazy [maxn*4] ; 
void down ( int id ) 
{
	int &t = lazy [id] ; 
	T [left].fi += t , T [right].fi += t ;
	T [left].se += t , T [right].se += t ;  
	lazy [left] += t , lazy [right] += t ; 
	t = 0 ; 
}

void update ( int id , int l , int r , int u , int v , int w )  
{
	if ( l > v || r < u ) return ; 
	if ( u <= l && r <= v ) 
	{
		T [id].fi += w , T [id].se += w ; 
		lazy [id] += w ; 
		return ; 
	}
	int mid = (l+r)/2 ; 
	down (id) ; 
	update (left,l,mid,u,v,w) ; 
	update (right,mid+1,r,u,v,w) ; 
	T [id].fi = min (T[left].fi,T[right].fi) ; 
	T [id].se = max (T[left].se,T[right].se) ; 
}

int main () 
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);cout.tie(0); 
//	rf () ; 
	cin >> n ; 
	
	for ( int i = 1 ; i <= n ; i ++ ) 
	{
		int r , s ; cin >> r >> s ; 
		if ( s == 1 ) update (1,1,n,1,r,1) ; 
		else update (1,1,n,1,r,-1) ;
		if ( T[1].fi >= 0 ) cout << ">\n" ; 
		else if ( T[1].se <= 0 ) cout << "<\n" ; 
		else cout << "?\n" ;  
	}
	
	
}

Compilation message

stones.cpp: In function 'void rf()':
stones.cpp:40:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  freopen ("bai1.inp","r",stdin) ;
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2516 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2516 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 18 ms 5112 KB Output is correct
12 Correct 30 ms 7516 KB Output is correct
13 Correct 31 ms 7504 KB Output is correct
14 Correct 35 ms 7504 KB Output is correct
15 Correct 31 ms 7504 KB Output is correct
16 Correct 32 ms 7508 KB Output is correct
17 Correct 31 ms 7512 KB Output is correct
18 Correct 31 ms 7512 KB Output is correct
19 Correct 30 ms 7672 KB Output is correct
20 Correct 30 ms 7584 KB Output is correct
21 Correct 31 ms 7612 KB Output is correct
22 Correct 32 ms 7768 KB Output is correct
23 Correct 31 ms 7516 KB Output is correct
24 Correct 31 ms 7516 KB Output is correct
25 Correct 31 ms 7504 KB Output is correct