QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#840266 | #9950. LIS | chenxinyang2006 | AC ✓ | 65ms | 7432kb | C++23 | 1.7kb | 2025-01-02 16:41:16 | 2025-01-02 16:41:16 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;
template <class T>
void chkmax(T &x,T y){
if(x < y) x = y;
}
template <class T>
void chkmin(T &x,T y){
if(x > y) x = y;
}
inline int popcnt(int x){
return __builtin_popcount(x);
}
inline int ctz(int x){
return __builtin_ctz(x);
}
/*ll power(ll p,int k = mod - 2){
ll ans = 1;
while(k){
if(k % 2 == 1) ans = ans * p % mod;
p = p * p % mod;
k /= 2;
}
return ans;
}*/
int T,n;
int a[100005],_l[100005],_r[100005],occ[100005],idx[100005];
vector <int> S[100005];
int ans[100005];
void solve(){
scanf("%d",&n);
fill(occ,occ + n + 1,0);
rep(i,1,n) S[i].clear();
rep(i,1,n){
scanf("%d",&a[i]);
S[a[i]].eb(i);
idx[i] = occ[a[i] - 1];
occ[a[i]] = i;
}
rep(i,1,n) scanf("%d%d",&_l[i],&_r[i]);
rep(i,1,n){
reverse(S[i].begin(),S[i].end());
int prv = -1;
for(int p:S[i]){
ans[p] = _l[p];
if(a[p] > 1) chkmax(ans[p],ans[idx[p]] + 1);
if(prv != -1) chkmax(ans[p],ans[prv]);
prv = p;
// printf("%d->%d %d\n",p,ans[p],_r[p]);
assert(ans[p] <= _r[p]);
}
}
rep(i,1,n) printf("%d%c",ans[i]," \n"[i == n]);
}
int main(){
#ifdef cxy
freopen("test.in","r",stdin);
#endif
scanf("%d",&T);
while(T--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5916kb
input:
4 6 1 2 3 2 4 3 0 5 2 4 3 3 1 2 3 5 1 5 5 1 2 1 3 1 100 200 200 300 200 400 400 500 100 500 7 1 2 3 1 1 4 2 0 3 0 3 0 3 0 3 0 3 0 3 0 3 2 1 1 1 2 2 3
output:
0 2 3 1 4 2 200 201 200 400 100 0 1 2 0 0 3 1 2 2
result:
ok Ok,Ok
Test #2:
score: 0
Accepted
time: 65ms
memory: 7432kb
input:
10001 52824 1 2 1 2 3 2 3 2 3 4 5 5 6 7 7 8 1 3 5 3 5 2 6 6 8 5 5 7 3 1 5 1 9 10 8 9 4 6 10 7 2 8 8 9 11 9 10 12 10 5 13 11 10 6 4 12 12 9 9 11 7 11 3 10 9 7 5 10 11 8 13 2 12 11 12 7 12 13 13 8 9 10 5 14 14 14 13 11 10 6 7 15 16 16 3 14 8 13 10 12 7 11 15 10 11 8 13 15 9 8 16 14 16 17 16 17 17 18 1...
output:
579267358 843758905 479476450 589735240 743102472 488321300 632579620 481304413 537214622 537931382 929152758 643061926 714894425 784635604 724991562 787914318 476066229 505049899 627879217 502799193 622074507 477703057 703610497 632272648 754872255 618163380 610565951 681728395 479058337 470055000 ...
result:
ok Ok,Ok
Extra Test:
score: 0
Extra Test Passed