QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168072 | #6807. Travel Dream | kkio | AC ✓ | 963ms | 13284kb | C++17 | 6.7kb | 2023-09-07 20:54:17 | 2023-09-07 20:54:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace FastIO {
struct IO {
char ibuf[(1 << 20) + 1], *iS, *iT, obuf[(1 << 20) + 1], *oS;
IO() : iS(ibuf), iT(ibuf), oS(obuf) {} ~IO() { fwrite(obuf, 1, oS - obuf, stdout); }
#if ONLINE_JUDGE
#define gh() (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin), (iS == iT ? EOF : *iS++) : *iS++)
#else
#define gh() getchar()
#endif
inline bool eof (const char &ch) { return ch == ' ' || ch == '\n' || ch == '\r' || ch == 't' || ch == EOF; }
inline long long read() {
char ch = gh();
long long x = 0;
bool t = 0;
while (ch < '0' || ch > '9') t |= ch == '-', ch = gh();
while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gh();
return t ? ~(x - 1) : x;
}
inline void read (char *s) {
char ch = gh(); int l = 0;
while (eof(ch)) ch = gh();
while (!eof(ch)) s[l++] = ch, ch = gh();
}
inline void read (double &x) {
char ch = gh(); bool t = 0;
while (ch < '0' || ch > '9') t |= ch == '-', ch = gh();
while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gh();
if (ch != '.') return t && (x = -x), void(); ch = gh();
for (double cf = 0.1; '0' <= ch && ch <= '9'; ch = gh(), cf *= 0.1) x += cf * (ch ^ 48);
t && (x = -x);
}
inline void pc (char ch) {
#ifdef ONLINE_JUDGE
if (oS == obuf + (1 << 20) + 1) fwrite(obuf, 1, oS - obuf, stdout), oS = obuf;
*oS++ = ch;
#else
putchar(ch);
#endif
}
template<typename _Tp>
inline void write (_Tp x) {
static char stk[64], *tp = stk;
if (x < 0) x = ~(x - 1), pc('-');
do *tp++ = x % 10, x /= 10;
while (x);
while (tp != stk) pc((*--tp) | 48);
}
inline void write (char *s) {
int n = strlen(s);
for (int i = 0; i < n; i++) pc(s[i]);
}
} io;
inline long long read () { return io.read(); }
template<typename Tp>
inline void read (Tp &x) { io.read(x); }
template<typename _Tp>
inline void write (_Tp x) { io.write(x); }
}
using namespace FastIO;
#define int long long
const int maxn=305,inf=1e18;
int n,m,k;
vector< tuple<int,int,int> > G[maxn];
bool col[maxn];
int f[6][maxn][maxn],up[maxn],vp[maxn],wp[maxn],h[maxn][maxn][3],idh[maxn][maxn][3];
mt19937 rnd(231232134);
void init1()
{
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[1][i][j]=-inf;
for(int i=1;i<=n;i++)f[1][i][i]=0;
}
void init2()
{
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[2][i][j]=-inf;
for(int i=1;i<=m;i++)
if(col[up[i]]==col[vp[i]])f[2][up[i]][vp[i]]=f[2][vp[i]][up[i]]=max(f[2][up[i]][vp[i]],wp[i]);
}
inline void init3()
{
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[3][i][j]=-inf;
for(int i=1;i<=n;i++)
for(auto [j,w1,id1]:G[i])
for(auto [k,w2,id2]:G[i])
if(col[i]==col[j]&&col[i]==col[k]&&j!=k)
f[3][k][j]=f[3][j][k]=max(f[3][j][k],w1+w2);
}
inline void init4()
{
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[4][i][j]=-inf;
for(int i=1;i<=m;i++)
{
if(col[up[i]]!=col[vp[i]])continue;
for(auto [j,w1,id1]:G[up[i]])
for(auto [k,w2,id2]:G[vp[i]])
if(col[up[i]]==col[j]&&col[vp[i]]==col[k]&&up[i]!=k&&vp[i]!=j&&k!=j)
f[4][j][k]=f[4][k][j]=max(f[4][j][k],w1+w2+wp[i]);
}
}
inline void upd(int v,int id,int i,int j)
{for(int t=0;t<3;t++)if(v>h[i][j][t]){swap(v,h[i][j][t]);swap(id,idh[i][j][t]);}}
inline int findminsec(int idn1,int idn2,int i,int j)
{for(int t=0;t<3;t++)if(idn1!=idh[i][j][t]&&idn2!=idh[i][j][t])return h[i][j][t];return -inf;}
inline void init5()
{
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[5][i][j]=h[i][j][0]=h[i][j][1]=h[i][j][2]=-inf;
for(int i=1;i<=n;i++)
for(auto [j,w1,id1]:G[i])
for(auto [k,w2,id2]:G[i])
if(col[i]==col[j]&&col[i]==col[k]&&j!=k)
{
upd(w1+w2,i,j,k);
upd(w1+w2,i,k,j);
}
for(int i=1;i<=m;i++)
for(int j=1;j<=m;j++)
{
if(col[up[i]]!=col[vp[i]]||col[up[i]]!=col[up[j]]||col[up[i]]!=col[vp[j]]||col[up[j]]!=col[vp[j]]||up[i]==up[j]||up[i]==vp[j]||vp[i]==up[j]||vp[i]==vp[j])continue;
f[5][up[i]][vp[j]]=max(f[5][up[i]][vp[j]],wp[i]+wp[j]+findminsec(up[i],vp[j],vp[i],up[j]));
f[5][up[i]][up[j]]=max(f[5][up[i]][up[j]],wp[i]+wp[j]+findminsec(up[i],up[j],vp[i],vp[j]));
f[5][vp[i]][vp[j]]=max(f[5][vp[i]][vp[j]],wp[i]+wp[j]+findminsec(vp[i],vp[j],up[i],up[j]));
f[5][vp[i]][up[j]]=max(f[5][vp[i]][up[j]],wp[i]+wp[j]+findminsec(vp[i],up[j],up[i],vp[j]));
}
}
signed main()
{
n=read(),m=read(),k=read();
for(int i=1;i<=m;i++)
up[i]=read(),vp[i]=read(),wp[i]=read();
for(int i=1;i<=m;i++)
{
G[up[i]].push_back({vp[i],wp[i],i});
G[vp[i]].push_back({up[i],wp[i],i});
}
int t1=k/2,t2=k-t1,ans=-inf;
if(k==3)
{
init2();
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
if(j!=up[i]&&j!=vp[i])
ans=max(ans,wp[i]+f[2][up[i]][j]+f[2][vp[i]][j]);
}
else
for(int sr=1;sr<=1000;sr++)
{
for(int i=1;i<=n;i++)col[i]=rnd()%2;
if(t1==1||t2==1)init1();
if(t1==2||t2==2)init2();
if(t1==3||t2==3)init3();
if(t1==4||t2==4)init4();
if(t1==5||t2==5)init5();
for(int i=1;i<=m;i++)
for(int j=1;j<=m;j++)
{
if(up[i]!=up[j]&&up[i]!=vp[j]&&vp[i]!=up[j]&&vp[i]!=vp[j])
{
if(col[up[i]]==0&&col[vp[i]]==1&&col[up[j]]==0&&col[vp[j]]==1)
ans=max(ans,f[t1][up[i]][up[j]]+f[t2][vp[i]][vp[j]]+wp[i]+wp[j]);
if(col[up[i]]==0&&col[vp[i]]==1&&col[vp[j]]==0&&col[up[j]]==1)
ans=max(ans,f[t1][up[i]][vp[j]]+f[t2][vp[i]][up[j]]+wp[i]+wp[j]);
if(col[vp[i]]==0&&col[up[i]]==1&&col[up[j]]==0&&col[vp[j]]==1)
ans=max(ans,f[t1][vp[i]][up[j]]+f[t2][up[i]][vp[j]]+wp[i]+wp[j]);
if(col[vp[i]]==0&&col[up[i]]==1&&col[vp[j]]==0&&col[up[j]]==1)
ans=max(ans,f[t1][vp[i]][vp[j]]+f[t2][up[i]][up[j]]+wp[i]+wp[j]);
}
}
}
if(ans>0)printf("%lld\n",ans);
else puts("impossible");
}
/*
6 13 3
2 1 99999998
3 1 99999998
3 2 100000000
4 1 99999998
4 2 100000000
4 3 99999998
5 1 99999999
5 2 99999998
5 3 99999998
5 4 99999998
6 1 99999998
6 2 99999998
6 3 99999998
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9864kb
input:
5 7 4 1 2 2 1 3 3 2 3 4 4 3 1 5 3 7 4 5 6 2 5 9
output:
21
result:
ok single line: '21'
Test #2:
score: 0
Accepted
time: 2ms
memory: 9768kb
input:
5 4 5 1 2 1 2 3 6 3 1 5 4 5 2
output:
impossible
result:
ok single line: 'impossible'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7880kb
input:
25 300 3 2 1 99999998 3 1 99999998 3 2 100000000 4 1 99999998 4 2 100000000 4 3 99999998 5 1 99999999 5 2 99999998 5 3 99999998 5 4 99999998 6 1 99999998 6 2 99999998 6 3 99999998 6 4 100000000 6 5 100000000 7 1 100000000 7 2 99999998 7 3 99999998 7 4 100000000 7 5 99999999 7 6 100000000 8 1 1000000...
output:
300000000
result:
ok single line: '300000000'
Test #4:
score: 0
Accepted
time: 248ms
memory: 7852kb
input:
25 300 4 2 1 99999998 3 1 99999999 3 2 100000000 4 1 100000000 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999998 5 3 100000000 5 4 99999998 6 1 100000000 6 2 100000000 6 3 100000000 6 4 99999999 6 5 99999999 7 1 99999998 7 2 99999999 7 3 99999998 7 4 100000000 7 5 99999998 7 6 100000000 8 1 1000...
output:
400000000
result:
ok single line: '400000000'
Test #5:
score: 0
Accepted
time: 259ms
memory: 10088kb
input:
25 300 5 2 1 100000000 3 1 100000000 3 2 99999999 4 1 99999998 4 2 99999999 4 3 100000000 5 1 100000000 5 2 100000000 5 3 99999999 5 4 99999999 6 1 99999998 6 2 100000000 6 3 99999998 6 4 100000000 6 5 100000000 7 1 99999999 7 2 99999998 7 3 100000000 7 4 99999999 7 5 99999998 7 6 100000000 8 1 1000...
output:
500000000
result:
ok single line: '500000000'
Test #6:
score: 0
Accepted
time: 259ms
memory: 9884kb
input:
25 300 6 2 1 99999998 3 1 99999999 3 2 99999998 4 1 100000000 4 2 99999998 4 3 100000000 5 1 99999998 5 2 99999999 5 3 100000000 5 4 99999999 6 1 100000000 6 2 99999998 6 3 99999998 6 4 99999998 6 5 99999998 7 1 100000000 7 2 99999998 7 3 99999998 7 4 99999998 7 5 99999999 7 6 99999999 8 1 99999999 ...
output:
600000000
result:
ok single line: '600000000'
Test #7:
score: 0
Accepted
time: 367ms
memory: 10020kb
input:
25 300 7 2 1 99999999 3 1 99999998 3 2 100000000 4 1 100000000 4 2 99999998 4 3 100000000 5 1 99999999 5 2 99999999 5 3 99999998 5 4 99999998 6 1 99999998 6 2 99999999 6 3 99999998 6 4 99999999 6 5 99999998 7 1 99999999 7 2 100000000 7 3 99999999 7 4 100000000 7 5 99999999 7 6 100000000 8 1 99999998...
output:
700000000
result:
ok single line: '700000000'
Test #8:
score: 0
Accepted
time: 355ms
memory: 7976kb
input:
25 300 8 2 1 100000000 3 1 99999999 3 2 99999999 4 1 99999999 4 2 99999999 4 3 99999998 5 1 99999999 5 2 99999998 5 3 99999998 5 4 99999999 6 1 99999999 6 2 100000000 6 3 100000000 6 4 100000000 6 5 100000000 7 1 100000000 7 2 99999998 7 3 100000000 7 4 100000000 7 5 99999998 7 6 100000000 8 1 99999...
output:
800000000
result:
ok single line: '800000000'
Test #9:
score: 0
Accepted
time: 669ms
memory: 12192kb
input:
25 300 9 2 1 100000000 3 1 100000000 3 2 99999998 4 1 100000000 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999998 5 3 99999999 5 4 100000000 6 1 99999999 6 2 99999998 6 3 99999998 6 4 100000000 6 5 99999999 7 1 99999999 7 2 99999998 7 3 99999999 7 4 99999999 7 5 99999998 7 6 100000000 8 1 100000...
output:
900000000
result:
ok single line: '900000000'
Test #10:
score: 0
Accepted
time: 556ms
memory: 10208kb
input:
25 300 10 2 1 100000000 3 1 100000000 3 2 99999998 4 1 99999998 4 2 99999998 4 3 100000000 5 1 99999999 5 2 99999999 5 3 100000000 5 4 100000000 6 1 99999999 6 2 99999999 6 3 100000000 6 4 99999999 6 5 99999998 7 1 99999999 7 2 100000000 7 3 99999998 7 4 99999999 7 5 100000000 7 6 99999999 8 1 99999...
output:
1000000000
result:
ok single line: '1000000000'
Test #11:
score: 0
Accepted
time: 553ms
memory: 10040kb
input:
25 300 10 2 1 99999998 3 1 99999999 3 2 100000000 4 1 99999998 4 2 100000000 4 3 100000000 5 1 99999999 5 2 99999999 5 3 100000000 5 4 100000000 6 1 100000000 6 2 99999998 6 3 99999999 6 4 100000000 6 5 99999999 7 1 99999999 7 2 100000000 7 3 99999999 7 4 99999998 7 5 99999998 7 6 99999999 8 1 99999...
output:
1000000000
result:
ok single line: '1000000000'
Test #12:
score: 0
Accepted
time: 556ms
memory: 10208kb
input:
25 300 10 2 1 99999998 3 1 99999999 3 2 99999999 4 1 99999999 4 2 99999999 4 3 100000000 5 1 99999999 5 2 99999999 5 3 99999998 5 4 99999998 6 1 99999999 6 2 100000000 6 3 100000000 6 4 99999998 6 5 99999998 7 1 99999998 7 2 99999999 7 3 100000000 7 4 100000000 7 5 100000000 7 6 99999999 8 1 9999999...
output:
1000000000
result:
ok single line: '1000000000'
Test #13:
score: 0
Accepted
time: 564ms
memory: 10024kb
input:
25 300 10 2 1 100000000 3 1 99999998 3 2 99999998 4 1 99999999 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999999 5 3 99999998 5 4 99999998 6 1 100000000 6 2 99999998 6 3 100000000 6 4 100000000 6 5 99999998 7 1 99999999 7 2 99999999 7 3 99999998 7 4 99999999 7 5 99999998 7 6 99999999 8 1 1000000...
output:
1000000000
result:
ok single line: '1000000000'
Test #14:
score: 0
Accepted
time: 288ms
memory: 9892kb
input:
200 300 7 158 4 19455984 49 17 41490257 164 20 34015263 165 81 59517833 100 43 9035359 95 87 65603323 21 4 93967028 188 100 27640444 155 30 23870278 5 4 9389586 146 143 17531415 173 24 96302901 120 38 67662324 180 74 31349370 159 80 90566938 157 94 17571038 179 60 3747316 184 159 88847169 148 143 46...
output:
512464840
result:
ok single line: '512464840'
Test #15:
score: 0
Accepted
time: 268ms
memory: 10016kb
input:
200 300 8 188 105 86013599 121 13 55936286 76 43 76278705 187 26 42682689 143 40 52350321 156 68 70873098 169 116 12698892 141 58 58624230 182 63 6586023 192 12 68122225 137 50 9382385 191 171 79286831 107 42 622389 106 76 77410692 176 114 6694022 58 10 86897486 199 114 15771321 167 3 78086780 142 7...
output:
648877821
result:
ok single line: '648877821'
Test #16:
score: 0
Accepted
time: 623ms
memory: 13284kb
input:
200 300 9 123 96 20892370 124 39 68549390 159 141 71568919 183 161 2548981 119 68 28505625 30 6 4991336 157 62 46856836 185 34 65937618 150 46 23426344 57 42 95862023 130 84 83643725 133 99 89615659 199 162 6075876 112 75 42349110 9 7 66231672 121 12 93444775 184 177 8399358 175 46 19498531 156 6 40...
output:
675650318
result:
ok single line: '675650318'
Test #17:
score: 0
Accepted
time: 587ms
memory: 11164kb
input:
200 300 10 130 111 85037457 28 14 41307685 114 18 29828752 167 29 99167142 74 42 80502852 48 35 98499069 80 45 15762815 126 52 14385391 198 163 78854226 183 163 90996473 189 55 5272301 53 47 69895104 150 120 49727262 65 47 15324391 137 111 85223993 175 172 88328915 68 16 82783554 106 79 92608976 191...
output:
835597957
result:
ok single line: '835597957'
Test #18:
score: 0
Accepted
time: 589ms
memory: 11276kb
input:
200 300 10 168 19 7783239 12 2 3453911 144 32 26168504 159 33 67181433 140 60 45210525 194 76 32547275 133 5 68999040 188 66 13328095 163 46 79104193 30 13 32563171 21 13 80702450 104 31 41583433 183 32 61833825 178 77 87006475 147 64 66105703 164 113 594050 168 53 49762457 33 9 1582506 74 30 500982...
output:
769345352
result:
ok single line: '769345352'
Test #19:
score: 0
Accepted
time: 590ms
memory: 11136kb
input:
200 300 10 183 58 31956328 88 65 68365085 197 56 94768333 118 62 43927076 171 23 88905479 143 36 45692082 157 52 93093189 48 35 64558756 189 123 77280059 4 3 40780766 154 126 77564942 200 29 93520666 117 91 62032495 114 85 94702986 110 88 84473518 43 14 6785035 173 49 56772271 106 16 7662446 61 56 7...
output:
736730012
result:
ok single line: '736730012'
Test #20:
score: 0
Accepted
time: 956ms
memory: 12148kb
input:
25 300 10 16 6 85278494 6 5 91520208 16 9 76416227 20 8 97569760 20 5 97797840 15 9 96147066 10 5 78399023 22 6 92498562 21 5 95380688 18 5 92881263 21 3 97050930 22 21 83467224 23 8 82952874 19 4 87754689 17 11 92451564 24 4 98106038 17 1 57249829 20 4 85323305 19 8 96172194 10 3 83280361 14 10 648...
output:
993693558
result:
ok single line: '993693558'
Test #21:
score: 0
Accepted
time: 963ms
memory: 10108kb
input:
26 300 10 10 5 95423214 25 7 95467914 18 10 12864622 22 4 85985536 10 2 93073531 23 1 81514087 24 4 68387436 19 15 71680141 22 12 89142892 8 5 98978862 17 15 61365325 12 10 81892595 18 11 51340289 21 7 3259673 18 4 82528376 20 8 95603399 15 7 45284789 9 8 44756614 21 11 94182260 12 1 85561508 21 15 ...
output:
982262154
result:
ok single line: '982262154'
Test #22:
score: 0
Accepted
time: 954ms
memory: 10020kb
input:
27 300 10 16 9 78787935 17 16 87857363 15 3 44531867 18 15 98126628 20 15 33127395 19 4 96434246 11 6 90249064 25 19 44640176 8 3 21870296 20 13 76832944 12 8 63095005 19 7 64990676 24 23 66471359 10 6 96474423 20 8 72237844 14 4 91375934 22 18 91320486 10 5 62023378 10 3 76652035 5 1 91276112 19 12...
output:
973129001
result:
ok single line: '973129001'
Test #23:
score: 0
Accepted
time: 951ms
memory: 10116kb
input:
30 300 10 25 24 74368549 24 23 61315735 29 16 67361971 8 3 72853138 24 17 95383642 24 14 75969164 30 28 16989494 10 5 87403467 16 10 92636926 22 5 35973350 15 3 48648588 28 25 69095987 30 8 60148769 18 5 46182643 15 12 98867865 22 9 23596100 30 24 90162888 30 17 69780575 25 21 94853004 20 18 4843716...
output:
957519222
result:
ok single line: '957519222'
Test #24:
score: 0
Accepted
time: 945ms
memory: 12124kb
input:
35 300 10 11 6 49240065 29 6 14732722 34 2 92311556 18 15 61696790 24 22 47331856 33 20 88047665 27 22 65048485 32 18 41641499 25 22 91956415 4 2 70536913 28 22 76699174 26 19 30741820 16 2 30351806 33 26 87230715 34 25 67503115 22 16 88432379 34 14 60529232 20 4 75634733 25 17 47267747 24 18 590865...
output:
960799378
result:
ok single line: '960799378'
Test #25:
score: 0
Accepted
time: 219ms
memory: 9968kb
input:
300 100 10 195 45 29418555 100 26 64762858 217 87 68055303 56 43 24551983 126 64 36687925 158 157 33708360 232 68 9090752 246 228 15728061 196 38 65339587 286 12 3350489 266 67 6204662 165 26 44694591 155 90 84213646 270 164 95272722 95 41 61474992 230 103 28950336 144 43 42563333 245 182 27996357 2...
output:
impossible
result:
ok single line: 'impossible'
Test #26:
score: 0
Accepted
time: 253ms
memory: 9828kb
input:
300 100 9 132 2 90107015 140 9 16006334 151 37 38856856 194 27 97156587 272 62 49986842 35 25 79590432 244 96 19666807 151 46 89170017 299 224 67267129 284 161 82999786 192 21 49473976 113 1 41427337 207 59 11547038 244 199 67556914 136 39 19644321 95 59 90731197 141 129 16738955 275 166 34925363 14...
output:
impossible
result:
ok single line: 'impossible'
Test #27:
score: 0
Accepted
time: 48ms
memory: 9628kb
input:
300 100 8 293 213 92264687 96 69 44136369 110 20 64507870 179 109 81955319 231 22 41387370 262 69 49950926 286 75 18095354 284 3 99664028 299 243 68572406 239 169 20628849 203 106 47093170 112 73 95397873 251 223 29074722 283 82 4401068 164 76 44299861 153 132 34789658 93 16 36842664 93 7 79156210 2...
output:
impossible
result:
ok single line: 'impossible'
Test #28:
score: 0
Accepted
time: 88ms
memory: 9764kb
input:
300 100 7 299 64 90592124 276 150 90990922 281 168 47069298 28 8 17435783 158 56 87570110 295 288 65134225 261 251 96436405 227 91 7622120 261 124 82238752 210 194 36413641 259 1 67842081 57 41 21446618 142 95 23394909 286 148 90144040 249 232 59567039 77 4 66223780 119 65 72114379 198 53 3526223 23...
output:
impossible
result:
ok single line: 'impossible'
Test #29:
score: 0
Accepted
time: 609ms
memory: 11312kb
input:
300 300 10 14 2 91704471 17 14 73110379 28 17 71881250 28 20 83850616 34 16 45430881 38 22 24978362 42 7 21603273 47 4 72289413 47 36 77110303 55 4 66163655 58 41 57273851 62 22 61858799 64 30 18405157 64 31 47969175 66 2 90187648 67 50 37598355 68 34 29768556 68 52 53462711 73 23 71647414 74 4 3071...
output:
708914074
result:
ok single line: '708914074'
Test #30:
score: 0
Accepted
time: 529ms
memory: 12360kb
input:
100 300 10 6 1 6722776 8 5 27350764 8 7 55335983 9 8 69660867 11 10 14868564 12 8 28241533 14 1 7139301 16 7 94344838 16 11 43171182 17 14 28164278 19 6 38546459 19 11 59637910 21 6 54383485 22 16 75818166 22 21 1812523 24 4 92079204 25 2 62507968 26 13 6807807 26 19 21864863 27 3 52950951 29 13 560...
output:
862108904
result:
ok single line: '862108904'
Test #31:
score: 0
Accepted
time: 549ms
memory: 10472kb
input:
100 300 9 3 1 88756841 4 3 11318762 11 5 5409234 11 10 29274569 12 7 93471151 15 5 31758949 15 8 8907660 16 2 8723405 16 4 1357562 18 3 65153432 18 5 23149857 19 5 9640804 19 9 46917884 20 1 1908333 20 14 58984683 21 9 97239722 22 2 24640545 22 7 71962885 23 7 49758602 23 9 43797214 23 16 48593326 2...
output:
790225207
result:
ok single line: '790225207'
Test #32:
score: 0
Accepted
time: 259ms
memory: 9960kb
input:
100 300 8 4 1 95140688 11 7 48829828 13 10 75633119 14 7 95057279 16 8 33187822 17 13 12788071 17 14 80724854 20 14 87231259 20 15 27984218 22 16 33495285 22 21 30856889 23 20 73256681 24 7 71654818 24 13 61400856 25 9 41635020 26 2 73470069 26 10 44748496 26 25 89407367 27 24 36712979 28 12 7182507...
output:
676279466
result:
ok single line: '676279466'
Test #33:
score: 0
Accepted
time: 283ms
memory: 10024kb
input:
100 300 7 10 7 68467775 11 2 21893912 14 4 12122101 16 9 33653222 17 4 56066750 17 15 94814173 18 1 53244933 19 5 670776 19 7 97599908 20 16 59054777 23 10 89458105 23 11 53445048 24 6 15937235 24 7 92951635 24 20 80999317 25 7 10925107 25 22 39096640 26 13 68835822 26 20 26409823 26 23 46515942 27 ...
output:
630823041
result:
ok single line: '630823041'
Test #34:
score: 0
Accepted
time: 531ms
memory: 10424kb
input:
300 300 10 1 2 31939072 2 3 79542917 3 4 73045211 4 5 17505052 5 6 49654542 6 7 81056776 7 8 63626389 8 9 83982758 9 10 77960648 10 11 8795135 11 12 81282194 12 13 1767378 13 14 62979299 14 15 34809907 15 16 73925064 16 17 31451370 17 18 25735458 18 19 96253981 19 20 63117700 20 21 72608286 21 22 73...
output:
impossible
result:
ok single line: 'impossible'
Test #35:
score: 0
Accepted
time: 238ms
memory: 9688kb
input:
300 299 7 1 2 31681839 2 3 40708048 3 4 13846711 4 5 96800095 5 6 53158038 6 7 64273971 7 8 20800027 8 9 12093051 9 10 8927506 10 11 2659817 11 12 53900634 12 13 73739468 13 14 38839356 14 15 7898319 15 16 29786696 16 17 69838755 17 18 72031972 18 19 48351254 19 20 37135716 20 21 23174641 21 22 1425...
output:
impossible
result:
ok single line: 'impossible'
Test #36:
score: 0
Accepted
time: 530ms
memory: 10312kb
input:
300 299 10 1 2 43464098 2 3 20246634 3 4 52992313 4 5 87366947 5 6 6480895 6 7 9722234 7 8 71924866 8 9 12633921 9 10 49081936 10 11 78220483 11 12 7784484 12 13 68106872 13 14 28816303 14 15 5032583 15 16 11535643 16 17 58202939 17 18 56126117 18 19 9375837 19 20 32301242 20 21 12175295 21 22 73960...
output:
impossible
result:
ok single line: 'impossible'
Test #37:
score: 0
Accepted
time: 240ms
memory: 9988kb
input:
151 300 7 1 2 30427946 1 151 49715840 2 3 50381236 2 151 16955847 3 4 25919678 3 151 94598927 4 5 5875846 4 151 11433374 5 6 18366759 5 151 33210967 6 7 67962542 6 151 28104875 7 8 53782418 7 151 86150124 8 9 4065956 8 151 61623891 9 10 65418000 9 151 60818406 10 11 52409070 10 151 66435453 11 12 76...
output:
569698321
result:
ok single line: '569698321'
Test #38:
score: 0
Accepted
time: 428ms
memory: 13104kb
input:
151 300 10 1 2 60717356 1 151 75131378 2 3 62498495 2 151 60643908 3 4 68161302 3 151 78837458 4 5 25488220 4 151 24784692 5 6 68707215 5 151 63855861 6 7 84541428 6 151 82404160 7 8 24987810 7 151 12633037 8 9 59940719 8 151 40721829 9 10 19031421 9 151 12169594 10 11 72302219 10 151 93071738 11 12...
output:
737011763
result:
ok single line: '737011763'
Test #39:
score: 0
Accepted
time: 502ms
memory: 10524kb
input:
102 300 9 1 2 63695799 1 101 36103892 1 102 88244466 2 3 71018731 2 101 89444100 2 102 46947399 3 4 19139496 3 101 51222992 3 102 1457664 4 5 50298697 4 101 64765264 4 102 36782119 5 6 86356861 5 101 61769452 5 102 92689777 6 7 80726198 6 101 30553910 6 102 74919001 7 8 223591 7 101 88761014 7 102 8...
output:
786340679
result:
ok single line: '786340679'
Test #40:
score: 0
Accepted
time: 455ms
memory: 10556kb
input:
102 300 10 1 2 34763532 1 101 39024837 1 102 91973771 2 3 91815921 2 101 24927477 2 102 87511265 3 4 30945053 3 101 89413913 3 102 19751470 4 5 30220858 4 101 86027815 4 102 98518981 5 6 25148936 5 101 17476897 5 102 9506222 6 7 71311859 6 101 28710183 6 102 99950892 7 8 39548161 7 101 4023040 7 102...
output:
841322281
result:
ok single line: '841322281'
Test #41:
score: 0
Accepted
time: 468ms
memory: 12448kb
input:
78 300 10 1 2 14338284 1 76 82661824 1 77 94299433 1 78 87515599 2 3 70747762 2 76 33143089 2 77 36388470 2 78 98667725 3 4 34329609 3 76 39059507 3 77 98523781 3 78 9747680 4 5 88375666 4 76 60363288 4 77 40666358 4 78 62628455 5 6 91836216 5 76 53240636 5 77 52856233 5 78 15891322 6 7 35368578 6 7...
output:
876525350
result:
ok single line: '876525350'
Test #42:
score: 0
Accepted
time: 491ms
memory: 12260kb
input:
55 300 10 1 2 48522766 1 51 62977988 1 52 64489024 1 53 38243119 1 54 55962435 1 55 30419735 2 3 59963013 2 51 785656 2 52 54964271 2 53 88275782 2 54 95429001 2 55 34742982 3 4 31924850 3 51 85227711 3 52 29854061 3 53 1359408 3 54 39808625 3 55 40539620 4 5 44971442 4 51 89484982 4 52 19052276 4 5...
output:
941034110
result:
ok single line: '941034110'
Test #43:
score: 0
Accepted
time: 546ms
memory: 12352kb
input:
250 300 10 1 2 100000000 1 3 100000000 2 4 100000000 2 5 100000000 3 6 100000000 3 7 100000000 4 8 100000000 4 9 100000000 5 10 100000000 5 11 100000000 6 12 100000000 6 13 100000000 7 14 100000000 7 15 100000000 8 16 100000000 8 17 100000000 9 18 100000000 9 19 100000000 10 20 100000000 10 21 10000...
output:
985547849
result:
ok single line: '985547849'
Test #44:
score: 0
Accepted
time: 580ms
memory: 12184kb
input:
25 300 10 1 2 79500 1 3 21 2 3 1 1 4 58 2 4 16 3 4 71379 1 5 32 2 5 38 3 5 33 4 5 42 1 6 39 2 6 69 3 6 77 4 6 35 5 6 73391 1 7 65 2 7 23 3 7 62 4 7 45 5 7 50 6 7 8 1 8 77 2 8 8 3 8 51 4 8 14 5 8 33 6 8 61 7 8 76959 1 9 47 2 9 35 3 9 44 4 9 66 5 9 42 6 9 38 7 9 53 8 9 14 1 10 47 2 10 55 3 10 54 4 10 ...
output:
390033
result:
ok single line: '390033'
Test #45:
score: 0
Accepted
time: 330ms
memory: 10016kb
input:
64 259 10 1 2 1 2 3 1 2 4 1 3 4 1 2 5 1 3 5 1 4 5 1 2 6 1 3 6 1 4 6 1 5 6 1 2 7 1 3 7 1 4 7 1 5 7 1 6 7 1 2 8 1 3 8 1 4 8 1 5 8 1 6 8 1 7 8 1 2 9 1 3 9 1 4 9 1 5 9 1 6 9 1 7 9 1 8 9 1 2 10 1 3 10 1 4 10 1 5 10 1 6 10 1 7 10 1 8 10 1 9 10 1 1 11 1 11 12 1 11 13 1 12 13 1 11 14 1 12 14 1 13 14 1 11 15...
output:
impossible
result:
ok single line: 'impossible'
Test #46:
score: 0
Accepted
time: 338ms
memory: 12272kb
input:
65 261 10 1 2 1 2 3 1 2 4 1 3 4 1 2 5 1 3 5 1 4 5 1 2 6 1 3 6 1 4 6 1 5 6 1 2 7 1 3 7 1 4 7 1 5 7 1 6 7 1 2 8 1 3 8 1 4 8 1 5 8 1 6 8 1 7 8 1 2 9 1 3 9 1 4 9 1 5 9 1 6 9 1 7 9 1 8 9 1 2 10 1 3 10 1 4 10 1 5 10 1 6 10 1 7 10 1 8 10 1 9 10 1 1 11 1 11 12 1 11 13 1 12 13 1 11 14 1 12 14 1 13 14 1 11 15...
output:
10
result:
ok single line: '10'
Test #47:
score: 0
Accepted
time: 463ms
memory: 12288kb
input:
58 287 10 2 1 1 3 1 1 3 2 1 4 1 1 4 2 1 4 3 1 5 1 1 5 2 1 5 3 1 5 4 1 6 1 1 6 2 1 6 3 1 6 4 1 6 5 1 7 1 1 7 2 1 7 3 1 7 4 1 7 5 1 7 6 1 8 1 1 8 2 1 8 3 1 8 4 1 8 5 1 8 6 1 8 7 1 9 1 1 9 2 1 9 3 1 9 4 1 9 5 1 9 6 1 9 7 1 9 8 1 10 1 1 10 2 1 10 3 1 10 4 1 10 5 1 10 6 1 10 7 1 10 8 1 10 9 1 11 1 1 11 2...
output:
20
result:
ok single line: '20'
Test #48:
score: 0
Accepted
time: 455ms
memory: 12044kb
input:
34 289 9 1 18 10 1 19 4 1 20 2 1 21 2 1 22 1 1 23 1 1 24 8 1 25 9 1 26 5 1 27 5 1 28 10 1 29 7 1 30 10 1 31 6 1 32 3 1 33 2 1 34 6 2 18 8 2 19 9 2 20 5 2 21 7 2 22 1 2 23 4 2 24 6 2 25 8 2 26 3 2 27 10 2 28 1 2 29 8 2 30 2 2 31 4 2 32 6 2 33 10 2 34 6 3 18 8 3 19 7 3 20 9 3 21 10 3 22 8 3 23 6 3 24 ...
output:
impossible
result:
ok single line: 'impossible'
Test #49:
score: 0
Accepted
time: 488ms
memory: 12232kb
input:
42 298 9 1 18 90848 1 19 41014 1 20 19928 1 21 97523 1 22 19035 1 23 14584 1 24 18060 1 25 70194 1 26 98809 1 27 98828 1 28 79943 1 29 45265 1 30 45141 1 31 91910 1 32 64743 1 33 84132 1 34 58287 2 18 27076 2 19 21091 2 20 58321 2 21 74457 2 22 77896 2 23 43418 2 24 64026 2 25 17042 2 26 41480 2 27 ...
output:
9
result:
ok single line: '9'
Test #50:
score: 0
Accepted
time: 456ms
memory: 10204kb
input:
25 300 10 2 1 1 3 1 1 3 2 1 4 1 1 4 2 1 4 3 1 5 1 1 5 2 1 5 3 1 5 4 1 6 1 1 6 2 1 6 3 1 6 4 1 6 5 1 7 1 1 7 2 1 7 3 1 7 4 1 7 5 1 7 6 1 8 1 1 8 2 1 8 3 1 8 4 1 8 5 1 8 6 1 8 7 1 9 1 1 9 2 1 9 3 1 9 4 1 9 5 1 9 6 1 9 7 1 9 8 1 10 1 1 10 2 1 10 3 1 10 4 1 10 5 1 10 6 1 10 7 1 10 8 1 10 9 1 11 1 1 11 2...
output:
10
result:
ok single line: '10'