QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554850 | #8332. Two in One | CarroT1212 | WA | 0ms | 3832kb | C++14 | 1.1kb | 2024-09-09 16:37:54 | 2024-09-09 16:37:55 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std; bool MEM;
using ll=long long; using ld=long double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
const int I=1e9,N=1e5+7;
const ll J=1e18;
int n,a[N],c[N],c1,c2;
int mx,mp,cx,cp;
int ans,al,ar,cl,cr;
void mian() {
scanf("%d",&n),ans=mx=mp=cx=cp=c1=c2=0;
for (int i=1;i<=n;i++) c[i]=0;
for (int i=1;i<=n;i++) scanf("%d",&a[i]),c[a[i]]++;
if (c[a[1]]==n) return cout<<n<<"\n1 "<<n<<"\n"<<a[1]<<" "<<a[1]<<"\n",void();
for (int i=1;i<=n;i++) {
if (c[i]>mx) cx=mx,cp=mp,mx=c[i],mp=i;
else if (c[i]>cx) cx=c[i],cp=i;
}
for (int i=1;i<=n;i++) {
if (a[i]==mp) c1++;
else if (a[i]==cp) c2++;
if ((c1|c2)>ans) ans=c1|c2,al=1,ar=i,cl=mp,cr=cp;
}
cout<<ans<<"\n"<<al<<" "<<ar<<"\n"<<cl<<" "<<cr<<"\n";
}
bool ORY; int main() {
// freopen("ttheal2.in","r",stdin);
// freopen("ttheal.in","r",stdin);
// freopen("ttheal.out","w",stdout);
// while (1)
int t; for (scanf("%d",&t);t--;)
mian();
cerr<<"\n"<<abs(&MEM-&ORY)/1048576<<"MB";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3832kb
input:
1 7 1 2 3 4 3 2 1
output:
3 1 6 1 2
result:
wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements