답안 #681008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681008 2023-01-12T08:39:23 Z Cutebol 돌 무게 재기 (IZhO11_stones) C++17
100 / 100
71 ms 7456 KB
#include <bits/stdc++.h>
 
using namespace std;
 
void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define Raiden ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define itn int
#define endl "\n"
#define ff first
#define ss second
   
const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e9 ;

int n ;
int lz[4*N] , mn[4*N] , mx[N*4] ;

void push( int l , int r , int v ){
	if ( lz[v] ){
		mn[v] += lz[v] ;
		mx[v] += lz[v] ;
		if ( l != r ){
			lz[v+v] += lz[v] ;
			lz[v+v+1] += lz[v] ;
		}
		lz[v] = 0 ;
	}
}

void upd ( int l , int r , int v , int tl = 1 , int tr = n , int x = 1 ){
//	cout << tl << ' ' << tr << ' ' << x << endl ;
	push( tl , tr , x ) ;
	if ( tr < l || tl > r ) return ;
	if ( tr <= r && tl >= l ){
		lz[x] += v ;
		push( tl , tr , x ) ;
		return ;
	}
	int mid = ( tl + tr ) / 2 ;
	upd( l , r , v , tl , mid , x + x ) ;
	upd( l , r , v , mid + 1 , tr , x + x + 1 ) ;
	mn[x] = min ( mn[x+x] , mn[x+x+1] )	;
	mx[x] = max ( mx[x+x] , mx[x+x+1] ) ;
}

void solve(){
	
	cin >> n ;
	for ( int i = 0 ; i < n ; i ++ ){
		int a , b , s = 1 ;
		cin >> a >> b ;
		if ( b == 2 ) s = -1 ;
		upd( 1 , a , s ) ;
		if ( mn[1] >= 0 && mx[1] > 0 ) cout << ">\n" ;
		else if ( mn[1] < 0 && mx[1] <= 0 ) cout << "<\n" ;
		else cout << "?\n" ;
	} 
	
}
 
signed main(){
//  fopn("blocks") ;
   	Raiden ;
    int t = 1 ;
//    	cin >> t ;
    while ( t -- ) solve() ; 
}

Compilation message

stones.cpp: In function 'void fopn(std::string)':
stones.cpp:5:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:5:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 30 ms 3920 KB Output is correct
12 Correct 71 ms 7260 KB Output is correct
13 Correct 40 ms 7412 KB Output is correct
14 Correct 41 ms 7384 KB Output is correct
15 Correct 40 ms 7364 KB Output is correct
16 Correct 41 ms 7420 KB Output is correct
17 Correct 42 ms 7372 KB Output is correct
18 Correct 44 ms 7348 KB Output is correct
19 Correct 41 ms 7408 KB Output is correct
20 Correct 40 ms 7384 KB Output is correct
21 Correct 40 ms 7372 KB Output is correct
22 Correct 59 ms 7416 KB Output is correct
23 Correct 39 ms 7360 KB Output is correct
24 Correct 39 ms 7456 KB Output is correct
25 Correct 40 ms 7360 KB Output is correct