QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87093#5098. 第一代图灵机enh0 14ms4064kbC++141.3kb2023-03-11 17:13:452023-03-11 17:13:48

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 17:13:48]
  • Judged
  • Verdict: 0
  • Time: 14ms
  • Memory: 4064kb
  • [2023-03-11 17:13:45]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std ;

const int N = 5005 ;
int n , m , q , a[N] , c[N] , vis[N] , suf[N] ;

set < int > st[N] ;
#define IT set<int>::iterator

int main ( ) {
	cin >> n >> m >> q ;
	if ( n > 5000 ) exit ( 0 ) ;
	for ( int i = 1 ; i <= n ; ++ i )
		cin >> a [ i ] , a [ i ] += a [ i - 1 ] ;
	for ( int i = 1 ; i <= n ; ++ i ) {
		cin >> c [ i ] ;
		st [ c [ i ] ] .insert ( i ) ;
	}
	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 ;
	}
	for ( int i = 1 ; i <= q ; ++ i ) {
		int op ;
		cin >> op ;
		if ( op == 1 ) {
			int l , r ;
			cin >> l >> r ;
			int la = r + 1 , ans = 0 ;
			for ( int j = r ; j >= l ; -- j ) {
				ans = max ( ans , a [ la - 1 ] - a [ j ] ) ;
				la = min ( la , suf [ j ] ) ;
			}
			ans = max ( ans , a [ la - 1 ] - a [ l - 1 ] ) ;
			cout << ans << "\n" ;
		}
		else {
			int x , y ;
			cin >> x >> y ;
			
			IT it = st [ c [ x ] ] .lower_bound ( x ) , jt = it ; ++ jt ;
			if ( it != st [ c [ x ] ] .begin ( ) )
				suf [ *it ] = *jt ;
			
			jt = st [ y ] .lower_bound ( x ) , it = jt ;
			suf [ x ] = *jt ;
			if ( ! st [ y ] .empty ( ) && it != st [ y ] .begin ( ) ) {
				-- it ;
				suf [ *it ] = x ;
			}
		}
	}
	return 0 ;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 14ms
memory: 4064kb

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:

118571
90725
79596
95154
95154
94493
72411
100567
100567
100567
100567
90725
100567
100567
90725
118571
94493
95154
58191
118571
100567
100567
100567
39374
89208
118571
99923
100567
100567
95724
87252
100567
118571
100567
100567
100567
100567
100567
100567
26617
100567
99923
100567
118571
100567
100...

result:

wrong answer 243rd lines differ - expected: '62908', found: '56641'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 2ms
memory: 3552kb

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:


result:

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

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 3544kb

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:


result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%