QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21615 | #2848. 城市地铁规划 | hy_zheng_zai_nei_juan# | WA | 5ms | 18828kb | C++20 | 2.2kb | 2022-03-07 16:42:26 | 2022-05-08 03:43:03 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
#define BUF_SIZE 100000
bool IOerror=0;
inline char nc()
{
static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
if (p1==pend)
{
p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
if (pend==p1) {IOerror=1; return -1;}
}
return *p1++;
}
inline bool blank(char ch) {return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
inline ll read()
{
bool sign=0; char ch=nc(); ll x=0;
for (; blank(ch); ch=nc());
if (IOerror)return 0;
if (ch=='-')sign=1,ch=nc();
for (; ch>='0'&&ch<='9'; ch=nc())x=x*10+ch-'0';
if (sign)x=-x;
return x;
}
#undef BUF_SIZE
};
using namespace fastIO;
#define mod 59393
int a[1000010],w[1000010],f[1000010],pre[1000010],n,k,p[1000010],deg[1000010];
vector<int>v,v2;
void solve2()
{
for(int i=1;i<=n-2;i++)p[i]=v[i-1],deg[p[i]]++;
int cur=1;
for(int i=0;i<=n-2;){
while(deg[cur]) cur++;f[cur]=p[++i];
while(!--deg[p[i]]&&p[i]<cur) f[p[i]]=p[i+1],i++;
cur++;
} f[p[n-2]]=n;//for(int i=1;i<=n-1;i++) printf("%d\n",f[i]);
for(int i=1;i<=n-1;i++) cout<<i<<' '<<f[i]<<'\n';
}
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=qr,k=qr;
for(int i=0; i<=k; i++)
{
in(a[i]);
}
for(int i=1; i<=n; i++)
{
for(int j=k; j>=1; j--)
{
w[i]+=a[j];
w[i]*=i;
w[i]%=mod;
}
w[i]+=a[0];
w[i]%=mod;
}
memset(f,128,sizeof(f));
f[0]=w[1]*n;
for(int i=1; i<=n-2; i++)
{
for(int j=i; j<=n-2; j++)
{
if(f[j-i]+w[i+1]-w[1]>f[j])f[j]=f[j-i]+w[i+1]-w[1],pre[j]=i;
}
}
int now=n-2,i=0;
while(now)
{
// cout<<pre[now]<<'\n';
i++;
for(int j=1; j<=pre[now]; j++)v.push_back(i);
now-=pre[now];
}
// auto e=pruefer_decode(v);
cout<<n-1<<' '<<f[n-2]<<'\n';
solve2();
// for(auto i:e)cout<<i.first<<' '<<i.second<<'\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 18068kb
input:
63 7 4 50 14 48 33 13 44 24
output:
62 992106 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 63 32 1 33 1 34 2 35 3 36 4 37 5 38 6 39 7 40 8 41 9 42 10 43 11 44 12 45 13 46 14 47 15 48 16 49 17 50 18 51 19 52 20 53 21...
result:
ok
Test #2:
score: 0
Accepted
time: 3ms
memory: 15980kb
input:
208 7 23 28 14 16 46 28 26 28
output:
207 3317121 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 18092kb
input:
2928 3 27 20 7 29
output:
2927 13889888 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 ...
result:
ok
Test #4:
score: 0
Accepted
time: 3ms
memory: 18024kb
input:
320 3 46 42 15 15
output:
319 1260206 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 320 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 3 52 3 53 3 54 3 55 3 56 3 5...
result:
ok
Test #5:
score: 0
Accepted
time: 3ms
memory: 17900kb
input:
380 5 41 27 8 3 31 0
output:
379 3140470 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #6:
score: 0
Accepted
time: 4ms
memory: 15988kb
input:
365 5 35 20 24 29 3 25
output:
364 3508667 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #7:
score: 0
Accepted
time: 3ms
memory: 18012kb
input:
318 6 4 44 46 6 37 14 49
output:
317 6799456 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #8:
score: 0
Accepted
time: 3ms
memory: 17808kb
input:
416 6 30 23 4 16 45 32 19
output:
415 5383994 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #9:
score: 0
Accepted
time: 2ms
memory: 17952kb
input:
572 5 15 27 5 18 3 46
output:
571 9396678 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 18012kb
input:
531 8 20 13 35 27 41 43 36 25 5
output:
530 9024252 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #11:
score: 0
Accepted
time: 1ms
memory: 17880kb
input:
487 10 29 29 40 45 5 16 40 47 47 2 14
output:
486 18026623 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
result:
ok
Test #12:
score: 0
Accepted
time: 3ms
memory: 17932kb
input:
584 7 10 27 29 8 32 43 26 3
output:
583 11437238 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
result:
ok
Test #13:
score: 0
Accepted
time: 5ms
memory: 18828kb
input:
59 4 48 16 9 42 21
output:
58 422967 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 59 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 2 20 2 21 2 22 2 23 3 24 3 25 3 26 3 27 4 28 4 29 4 30 4 31 5 32 5 33 5 34 5 35 6 36 6 37 6 38 6 39 7 40 7 41 7 42 7 43 8 44 8 45 8 46 8 47 9 48 9 49 9 50 9 51 10 52 10 53 10 54 10 55 11 56 11 57 11 58 11
result:
ok
Test #14:
score: 0
Accepted
time: 3ms
memory: 17952kb
input:
561 3 22 31 17 49
output:
560 3223790 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #15:
score: 0
Accepted
time: 2ms
memory: 18020kb
input:
629 6 26 31 41 32 13 39 41
output:
628 13149156 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
result:
ok
Test #16:
score: 0
Accepted
time: 4ms
memory: 15852kb
input:
616 3 38 48 27 2
output:
615 1394108 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 616 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 2 52 2 53 2 54 2 55 2 56 2...
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 17948kb
input:
744 2 49 45 50
output:
743 1425426 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 744 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 5...
result:
ok
Test #18:
score: 0
Accepted
time: 2ms
memory: 15880kb
input:
629 7 27 18 48 24 37 38 6 3
output:
628 9258317 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #19:
score: 0
Accepted
time: 2ms
memory: 17936kb
input:
602 8 17 25 14 13 2 16 23 24 44
output:
601 9947756 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #20:
score: 0
Accepted
time: 3ms
memory: 15888kb
input:
900 2 9 13 12
output:
899 787522 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 900 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 5...
result:
ok
Test #21:
score: 0
Accepted
time: 3ms
memory: 17932kb
input:
839 7 12 12 28 33 35 29 14 17
output:
838 24516016 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
result:
ok
Test #22:
score: 0
Accepted
time: 3ms
memory: 17944kb
input:
768 7 27 3 40 6 39 9 48 31
output:
767 18960055 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 5...
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 17944kb
input:
783 3 25 19 31 45
output:
782 4263811 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...
result:
ok
Test #24:
score: -100
Wrong Answer
time: 2ms
memory: 16016kb
input:
2 4 24 9 31 45 15
output:
1 248 1 0
result:
wrong answer