QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850148 | #9663. Reverse Pairs Coloring | zhenjianuo2025 | TL | 676ms | 7896kb | C++20 | 1.8kb | 2025-01-09 20:53:25 | 2025-01-09 20:53:27 |
Judging History
answer
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define int long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
int ans=1;for(;y;y>>=1,x=1ll*x*x%mod)if(y&1)ans=1ll*x*ans%mod;return ans;
}
int n,p[300010],q[300010],ans;
void work(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>p[i];
q[p[i]]=i;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(j<p[i]&&i<q[j]&&q[j-1]<i&&p[i-1]<j){
++ans;
}
}
}
cout<<ans<<'\n';
}
bool Med;
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;while(T--)work();
// cerr<<"Time: "<<clock()<<" ms;\n";
// cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5624kb
input:
9 5 9 1 8 2 6 4 7 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5612kb
input:
2 1 2
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5696kb
input:
2 2 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5708kb
input:
12 12 11 10 9 8 7 6 5 4 3 2 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5612kb
input:
12 2 5 3 7 1 12 11 9 8 4 10 6
output:
8
result:
ok single line: '8'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
12 1 2 3 4 5 6 7 8 9 10 11 12
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5620kb
input:
144 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61...
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 5692kb
input:
144 78 106 141 21 115 2 14 64 124 91 117 121 30 99 144 55 94 137 38 27 40 72 59 46 50 109 84 15 87 108 52 23 74 4 140 70 63 58 105 113 77 10 35 66 130 34 96 86 16 65 12 92 83 5 95 36 45 8 79 132 75 57 98 93 119 125 26 18 136 127 73 90 3 123 53 139 142 37 103 24 133 111 143 67 76 43 114 42 44 135 22 ...
output:
699
result:
ok single line: '699'
Test #9:
score: 0
Accepted
time: 0ms
memory: 5696kb
input:
144 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 3ms
memory: 5708kb
input:
1728 1728 1727 1726 1725 1724 1723 1722 1721 1720 1719 1718 1717 1716 1715 1714 1713 1712 1711 1710 1709 1708 1707 1706 1705 1704 1703 1702 1701 1700 1699 1698 1697 1696 1695 1694 1693 1692 1691 1690 1689 1688 1687 1686 1685 1684 1683 1682 1681 1680 1679 1678 1677 1676 1675 1674 1673 1672 1671 1670 ...
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 0ms
memory: 5780kb
input:
1728 802 233 421 541 844 722 70 119 697 499 1699 1323 1537 1053 551 1125 736 686 1378 630 1070 192 1650 652 291 1182 1405 848 684 1557 100 1704 329 504 611 795 1242 1548 680 1355 1693 66 479 1194 607 316 913 1343 276 701 78 737 279 804 1438 30 754 1115 745 1017 767 1046 920 683 988 1494 501 669 1658...
output:
83738
result:
ok single line: '83738'
Test #12:
score: 0
Accepted
time: 3ms
memory: 5712kb
input:
1728 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 274ms
memory: 5732kb
input:
20736 20736 20735 20734 20733 20732 20731 20730 20729 20728 20727 20726 20725 20724 20723 20722 20721 20720 20719 20718 20717 20716 20715 20714 20713 20712 20711 20710 20709 20708 20707 20706 20705 20704 20703 20702 20701 20700 20699 20698 20697 20696 20695 20694 20693 20692 20691 20690 20689 20688 ...
output:
1
result:
ok single line: '1'
Test #14:
score: 0
Accepted
time: 676ms
memory: 5796kb
input:
20736 15428 2928 14988 4279 13247 8077 8128 5263 19240 2440 3234 3008 9868 13229 657 14625 7333 17930 9043 1743 3440 7846 5030 10290 14958 1451 9866 13357 3826 15385 7304 4033 12973 16937 131 5361 2814 6706 2681 5908 9738 15648 4911 18164 12531 10392 5428 6612 15193 9154 11479 8291 1187 1136 6330 10...
output:
11906581
result:
ok single line: '11906581'
Test #15:
score: 0
Accepted
time: 251ms
memory: 7896kb
input:
20736 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
output:
0
result:
ok single line: '0'
Test #16:
score: -100
Time Limit Exceeded
input:
248832 248832 248831 248830 248829 248828 248827 248826 248825 248824 248823 248822 248821 248820 248819 248818 248817 248816 248815 248814 248813 248812 248811 248810 248809 248808 248807 248806 248805 248804 248803 248802 248801 248800 248799 248798 248797 248796 248795 248794 248793 248792 248791...