QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87066#5098. 第一代图灵机enh0 394ms30616kbC++143.1kb2023-03-11 16:40:082023-03-11 16:45:10

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-11 16:45:10]
  • Judged
  • Verdict: 0
  • Time: 394ms
  • Memory: 30616kb
  • [2023-03-11 16:40:08]
  • Submitted

answer

#include <iostream>
#include <set>
using namespace std ;

int read ( ) {
	char ch = getchar ( ) ;
	int x = 0 ;
	while ( ch < '0' || ch > '9' )
		ch = getchar ( ) ;
	while ( ch >= '0' && ch <= '9' )
		x = x * 10 + ch - 48 , ch = getchar ( ) ;
	return x ;
}

const int N = 200005 ;
int n , m , q , a[N] , c[N] , vis[N] , suf[N] ;
int mif[N<<2] , ts[N<<2] , tls[N<<2] ;

set < int > st[N] ;

int find ( int k , int l , int r , int lim ) {
	if ( l == r )
		return a [ lim - 1 ] - a [ l ] ;
	int mid = ( l + r ) >> 1 ;
	if ( mif [ k << 1 | 1 ] > lim )
		return find ( k << 1 , l , mid , lim ) ;
	return max ( tls [ k ] , find ( k << 1 | 1 , mid + 1 , r , lim ) ) ;
}

void pushup ( int k , int l , int r ) {
	int ls = k << 1 , rs = k << 1 | 1 ;
	if ( mif [ ls ] > mif [ rs ] ) {
		ts [ k ] = ts [ rs ] ;
		tls [ k ] = 0 ;
		mif [ k ] = mif [ rs ] ;
	}
	else {
		int mid = ( l + r ) >> 1 ;
		tls [ k ] = find ( ls , l , mid , mif [ rs ] ) ;
		ts [ k ] = max ( tls [ k ] , ts [ rs ] ) ;
		mif [ k ] = mif [ ls ] ;
	}
}

void build ( int k , int l , int r ) {
	if ( l == r ) {
		mif [ k ] = suf [ l ] ;
		ts [ k ] = 0 ;
		return ;
	}
	int mid = ( l + r ) >> 1 ;
	build ( k << 1 , l , mid ) ;
	build ( k << 1 | 1 , mid + 1 , r ) ;
	pushup ( k , l , r ) ;
}

void change ( int k , int l , int r , int x , int y ) {
	if ( l == r ) {
		mif [ k ] = y ;
		ts [ k ] = 0 ;
		return ;
	}
	int mid = ( l + r ) >> 1 ;
	if ( x <= mid ) change ( k << 1 , l , mid , x , y ) ;
	else change ( k << 1 | 1 , mid + 1 , r , x , y ) ;
	pushup ( k , l , r ) ;
}

int lm ;
int query ( int k , int l , int r , int x , int y ) {
	if ( x <= l && r <= y ) {
		if ( mif [ k ] > lm ) return 0 ;
		int tmp = find ( k , l , r , lm ) ; lm = min ( lm , mif [ k ] ) ;
		return tmp ;
	}
	int mid = ( l + r ) >> 1 ;
	if ( x > mid ) return query ( k << 1 | 1 , mid + 1 , r , x , y ) ;
	if ( y <= mid ) return query ( k << 1 , l , mid , x , y ) ;
	int tmp1 = query ( k << 1 | 1 , mid + 1 , r , x , y ) ;
	int tmp2 = query ( k << 1 , l , mid , x , y ) ;
	return min ( tmp1 , tmp2 ) ;
}

#define IT set<int>::iterator

int main ( ) {
	n = read ( ) , m = read ( ) , q = read ( ) ;
	for ( int i = 1 ; i <= n ; ++ i )
		a [ i ] = read ( ) + a [ i - 1 ] ;
	for ( int i = 1 ; i <= n ; ++ i )
		c [ i ] = read ( ) ;
	for ( int i = 1 ; i <= m ; ++ i )
		vis [ i ] = n + 1 , st [ i ] .insert ( n + 1 ) ;
	for ( int i = n ; i ; -- i ) {
		suf [ i ] = vis [ c [ i ] ] ;
		vis [ c [ i ] ] = i ;
		st [ c [ i ] ] .insert ( i ) ;
	}
	build ( 1 , 1 , n ) ;
	while ( q -- ) {
		int op = read ( ) , x = read ( ) , y = read ( ) ;
		if ( op == 1 ) {
			lm = y + 1 ;
			cout << query ( 1 , 1 , n , x , y ) << "\n" ;
		}
		else {
			IT it = st [ c [ x ] ] .lower_bound ( x ) , jt = it ; ++ jt ;
			if ( it != st [ c [ x ] ] .begin ( ) )
				change ( 1 , 1 , n , *it , *jt ) , suf [ *it ] = *jt ;
			
			jt = st [ y ] .lower_bound ( x ) , it = jt ;
			change ( 1 , 1 , n , x , *jt ) ;
			suf [ x ] = *jt ;
			if ( ! st [ y ] .empty ( ) && it != st [ y ] .begin ( ) ) {
				-- it ;
				change ( 1 , 1 , n , *it , x ) ;
				suf [ *it ] = x ;
			}
		}
	}
	return 0 ;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 13392kb

input:

5000 200 5000
2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...

output:

0
0
43608
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
67533
0
0
0
0
0
0
0
0
0
0
0
0
35833
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10189
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st lines differ - expected: '118571', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 394ms
memory: 29596kb

input:

200000 10 200000
55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...

output:

0
0
252627
0
0
0
0
0
93441
0
0
0
0
0
0
0
0
0
0
364316
0
0
242891
0
0
0
0
145708
0
0
0
0
0
0
55121
0
0
0
0
269729
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
159781
0
0
0
0
0
0
0
0
438931
0
0
0
0
0
0
0
0
0
0
0
173556
0
0
0
0
0
129959
0
0
0
0
79963
0
0
152321
125086
0
0
0
506666
278184
0
0
0
0
0
27829
0...

result:

wrong answer 1st lines differ - expected: '1232419', found: '0'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 244ms
memory: 30616kb

input:

200000 20000 200000
30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st lines differ - expected: '46702944', found: '0'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%