You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
const int N = 8010 ;
struct Node {
int id ;
int value ;
bool operator < ( const Node & t ) const {
if ( value = = t . value ) return id < t . id ;
return value < t . value ;
}
} a [ N ] ;
int n , q ;
/*
测试结果:
1、不加cin优化: 有时3个点TLE,有时1个点TLE, 有时AC
2、加了cin优化: 每次AC
3、sacnf性能很快, 基本上与cin优化后相当
*/
int main ( ) {
//测试scanf版
scanf ( " %d%d " , & n , & q ) ;
for ( int i = 1 ; i < = n ; i + + ) {
scanf ( " %d " , & a [ i ] . value ) ;
a [ i ] . id = i ;
}
sort ( a + 1 , a + 1 + n ) ;
while ( q - - ) {
int op , x , v ;
scanf ( " %d " , & op ) ;
if ( op = = 1 ) {
scanf ( " %d%d " , & x , & v ) ;
for ( int i = 1 ; i < = n ; i + + )
if ( a [ i ] . id = = x ) {
a [ i ] . value = v ;
break ;
}
sort ( a + 1 , a + 1 + n ) ;
} else {
scanf ( " %d " , & x ) ;
for ( int i = 1 ; i < = n ; i + + )
if ( a [ i ] . id = = x ) {
printf ( " %d \n " , i ) ;
break ;
}
}
}
return 0 ;
}