QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#434335 | #8781. Element-Wise Comparison | ucup-team987# | WA | 294ms | 5752kb | C++20 | 2.6kb | 2024-06-08 15:44:53 | 2024-06-08 15:44:53 |
Judging History
answer
#include<iostream>
#include<random>
#include<cassert>
using namespace std;
#include<cstdio>
#include<cctype>
#include<string>
const int buffer_size=1<<20;
//input
int rd_char()
{
static char buf[buffer_size];
static int l=buffer_size,r=buffer_size;
if(l==r&&r==buffer_size)
{
r=fread(buf,sizeof(char),1<<20,stdin);
l=0;
}
if(l==r)return EOF;
return buf[l++];
}
unsigned int rd_uint()
{
int c;
unsigned int x=0;
while('0'<=(c=rd_char()))x=x*10+c-'0';
return x;
}
int rd_int()
{
bool neg=false;
int c=rd_char();
long long x=0;
if(c=='-')neg=true;
else x=c-'0';
while('0'<=(c=rd_char()))x=x*10+c-'0';
return neg?-x:x;
}
unsigned long long rd_ull()
{
int c;
unsigned long long x=0;
while('0'<=(c=rd_char()))x=x*10+c-'0';
return x;
}
long long rd_ll()
{
bool neg=false;
int c=rd_char();
long long x=0;
if(c=='-')neg=true;
else x=c-'0';
while('0'<=(c=rd_char()))x=x*10+c-'0';
return neg?-x:x;
}
string rd_str()
{
string ret;
int c;
while((c=rd_char())!='\n'&&c!=' '&&c!=EOF)ret+=c;
return ret;
}
//output
struct writer_struct{
char buf[buffer_size];
int l=0;
~writer_struct(){fwrite(buf,sizeof(char),l,stdout);}
}writer;
void flush()
{
fwrite(writer.buf,sizeof(char),writer.l,stdout);
fflush(stdout);
writer.l=0;
}
void wt(char c)
{
if(writer.l==buffer_size)
{
fwrite(writer.buf,sizeof(char),buffer_size,stdout);
writer.l=0;
}
writer.buf[writer.l++]=c;
}
void wt(unsigned int x)
{
if(x==0)wt('0');
else
{
char f[10];
int sz=0;
while(x)
{
f[sz++]=x%10+'0';
x/=10;
}
while(sz)wt(f[--sz]);
}
}
void wt(int x)
{
if(x<0)wt('-'),x=-x;
wt((unsigned int)x);
}
void wt(unsigned long long x)
{
if(x==0)wt('0');
else
{
char f[20];
int sz=0;
while(x)
{
f[sz++]=x%10+'0';
x/=10;
}
while(sz)wt(f[--sz]);
}
}
void wt(long long x)
{
if(x<0)wt('-'),x=-x;
wt((unsigned long long)x);
}
void wt(const char*s){while(*s!='\0')wt(*s++);}
void wt(const string&s){for(char c:s)wt(c);}
const int SZ=16;
int N,M;
unsigned short P[50000+SZ];
unsigned short cnt[SZ];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
if(false)
{
N=50000;
M=1;
mt19937 rng;
for(int i=0;i<N;i++)P[i]=rng();
}
else
{
N=rd_uint();
M=rd_uint();
for(int i=0;i<N;i++)P[i]=rd_uint();
}
unsigned int ans=0;
for(int ld=1;ld<=N-M;ld+=SZ)
{
int rd=ld+SZ;
for(int d=0;d<SZ;d++)cnt[d]=0;
for(int i=0;i<N-ld;i++)
{
for(int d=0;d<SZ;d++)cnt[d]++;
for(int d=0;d<SZ;d++)cnt[d]*=P[i+d+1]>P[i];
for(int d=0;d<SZ;d++)ans+=cnt[d]>=M;
}
}
wt(ans);
wt('\n');
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Wrong Answer
time: 294ms
memory: 5752kb
input:
50000 2 44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...
output:
307243231
result:
wrong answer expected '310780127', found '307243231'