QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#85159#5559. Guessing GametaniyaAC ✓133ms31992kbC++232.0kb2023-03-07 02:00:232023-03-07 02:00:27

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-07 02:00:27]
  • 评测
  • 测评结果:AC
  • 用时:133ms
  • 内存:31992kb
  • [2023-03-07 02:00:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=5e6+10;
int dfn[N*2],low[N*2];
int stk[N*2],top;
bool instk[N*2];
int scc_cnt;
int ts;
int id[N*2];
int ne[M],e[M],h[N*2],idx;
int n,m;
void add(int a,int b)
{
  ne[idx]=h[a],e[idx]=b,h[a]=idx++;
}
void tarjan(int u)
{
  dfn[u]=low[u]=++ts;
  stk[++top]=u,instk[u]=true;
  for(int i=h[u];~i;i=ne[i])
  {
    int j=e[i];
    if(!dfn[j])
    {
      tarjan(j);
      low[u]=min(low[u],low[j]);
    }else if(instk[j])low[u]=min(low[u],dfn[j]);
  }
  if(dfn[u]==low[u])
  {
    int y;
    scc_cnt++;
    do
    {   y=stk[top--];
      instk[y]=false;
      id[y]=scc_cnt;
    }while(y!=u);
  }
}
void solve()
{ 
  int n;

  memset(h,-1,sizeof h);
  cin>>n;

  vector<int>d(7);

  for(int i=0;i<7;i++)
    cin>>d[i];
  vector<int>prefix(8);
  for(int i=1;i<=7;i++)
    prefix[i]=prefix[i-1]+d[i-1];

  vector<vector<int>>now(n,vector<int>(7));
  for(int i=0;i<n;i++)
    for(int j=0;j<7;j++)
      cin>>now[i][j];

  int p1,p2;
  cin>>p1>>p2;
  for(int c=0;c<n;c++)
  {   

      for(int i=0;i<7;i++)
        for(int j=i+1;j<7;j++)
        {    

            int id1=prefix[i]+abs(now[c][i]);
            int id2=prefix[j]+abs(now[c][j]);
            if(id1==prefix[5]+abs(p1)&&id2==prefix[6]+abs(p2))continue;
            add(id1*2+!(now[c][i]>0),id2*2+(now[c][j]>0));
            add(id2*2+!(now[c][j]>0),id1*2+(now[c][i]>0));
        }
  }
  int id1=prefix[5]+abs(p1);
  int id2=prefix[6]+abs(p2);
  int v1=(p1>0);
  int v2=(p2>0);
  add(id1*2+(p1>0),id2*2+(p2>0));
  add(id2*2+!(p2>0),id1*2+!(p1>0));
  for(int i=2;i<=2*prefix[7]+1;i++)
    if(!dfn[i])
      tarjan(i);
  for(int i=1;i<=prefix[7];i++)
    if(id[i*2]==id[i*2+1]||(id[id1*2+1]<id[id1*2])==v1||(id[id2*2+1]<id[id2*2])==v2)
    {
      cout<<"impossible\n";
      return;
    }
    cout<<"possible\n";
    return;
}
signed main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 4256kb

input:

3
4 4 4 4 4 4 4
1 1 1 1 4 -2 1
2 2 2 2 -4 1 -1
3 3 3 3 -3 3 3
-2 -1

output:

impossible

result:

ok single line: 'impossible'

Test #2:

score: 0
Accepted
time: 2ms
memory: 4320kb

input:

3
4 4 4 4 4 4 4
4 3 2 1 4 1 1
2 4 4 2 2 4 2
2 3 3 4 1 3 2
-2 -1

output:

possible

result:

ok single line: 'possible'

Test #3:

score: 0
Accepted
time: 2ms
memory: 4236kb

input:

4
1 1 1 1 1 1 1
-1 -1 -1 -1 1 1 -1
-1 1 1 1 -1 -1 1
-1 -1 1 -1 -1 -1 1
-1 -1 -1 -1 -1 1 -1
-1 -1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 2ms
memory: 4296kb

input:

10
7 7 7 7 7 7 7
-3 -7 1 -5 1 2 4
5 -7 6 2 4 -7 2
5 -3 6 -3 -6 -2 -5
-7 3 -5 2 -1 -3 7
-4 -2 4 5 7 6 -3
1 1 5 -6 -3 -7 7
7 -5 5 -2 3 1 -7
-5 -2 -3 -4 -5 4 7
2 7 -2 -1 6 1 -7
2 3 3 1 -1 3 3
5 7

output:

impossible

result:

ok single line: 'impossible'

Test #5:

score: 0
Accepted
time: 0ms
memory: 4224kb

input:

10
7 7 7 7 7 7 7
4 1 -2 7 6 6 3
-6 5 2 4 -7 -7 3
-1 -4 -5 -3 4 -3 1
-5 -2 -7 7 4 -3 -3
-7 3 -5 -5 -1 4 -5
2 7 7 2 -1 5 -4
-4 -2 -6 5 2 -6 -4
-6 3 -1 3 4 -6 -7
-5 -5 -2 -7 -3 7 7
3 -2 6 -4 -2 6 4
7 -3

output:

impossible

result:

ok single line: 'impossible'

Test #6:

score: 0
Accepted
time: 2ms
memory: 4196kb

input:

10
7 7 7 7 7 7 7
-7 -2 2 -2 2 6 -7
-6 -5 -6 4 2 -1 5
-2 5 -4 -6 3 -6 -3
2 1 -7 5 3 1 4
-4 -4 3 -7 3 7 -4
-5 -3 -7 7 7 -6 -1
5 -2 5 -1 -3 1 -7
-3 -2 -2 -1 -1 -6 2
5 7 3 -3 2 3 4
3 6 -5 6 4 2 -2
5 1

output:

impossible

result:

ok single line: 'impossible'

Test #7:

score: 0
Accepted
time: 2ms
memory: 4248kb

input:

10
7 7 7 7 7 7 7
7 5 3 2 -6 7 -5
3 -1 1 6 5 -1 6
-6 7 -4 -2 7 4 3
4 -3 1 1 7 -6 6
-6 -1 -4 3 -5 3 2
-4 -6 -6 1 5 -1 3
-2 7 -6 6 -6 -1 -4
-3 4 2 5 5 -5 2
-4 -1 1 -4 -7 3 -5
7 2 7 5 2 -6 6
-7 -6

output:

possible

result:

ok single line: 'possible'

Test #8:

score: 0
Accepted
time: 0ms
memory: 4336kb

input:

4
3 3 3 3 3 3 3
1 -2 -1 3 1 2 1
3 -2 2 -1 2 3 1
3 1 3 -2 2 1 1
-2 -1 3 1 1 3 3
-3 -3

output:

possible

result:

ok single line: 'possible'

Test #9:

score: 0
Accepted
time: 3ms
memory: 4752kb

input:

1000
500 20 20 500 500 500 10
-115 -19 7 431 92 -225 10
-158 14 -8 -87 412 -60 8
160 -5 1 -416 -264 -372 -10
404 -9 -6 -438 383 396 8
170 -7 2 4 -285 -149 -4
338 -9 6 -173 354 -485 -6
483 -6 -3 -361 58 3 -3
246 -8 -4 122 172 -212 10
-188 6 -4 -60 -483 -222 -1
-366 -18 1 -117 -256 -419 -10
212 -2 -14...

output:

impossible

result:

ok single line: 'impossible'

Test #10:

score: 0
Accepted
time: 0ms
memory: 4768kb

input:

1000
500 20 20 500 500 500 10
180 -12 18 184 324 39 8
-441 -20 -11 182 422 270 5
321 -5 14 -15 53 490 1
-496 -12 14 -15 262 -31 -6
250 -19 7 -324 203 -210 8
68 -15 -7 92 131 480 1
-373 14 5 52 -347 -124 8
46 3 -17 162 394 47 -7
417 -6 3 -173 -33 111 9
-46 -13 -2 138 491 398 -10
-498 17 9 202 -344 33...

output:

impossible

result:

ok single line: 'impossible'

Test #11:

score: 0
Accepted
time: 73ms
memory: 24740kb

input:

40000
5000 5000 5000 5000 5000 5000 5000
4712 -4246 -3569 -2508 -502 -3965 1152
4221 -1238 -502 3638 -1816 -785 -484
-284 -1802 2845 940 -7 3329 319
-4869 -2196 -1187 -3358 -977 -4598 1464
2731 1530 -889 1697 -650 -3009 2293
2985 -1348 -3496 -3319 -4620 -941 -4068
3380 4323 -3622 3803 1999 -1527 347...

output:

impossible

result:

ok single line: 'impossible'

Test #12:

score: 0
Accepted
time: 50ms
memory: 24140kb

input:

50000
1 1 1 1 1 1 4994
-1 1 1 -1 -1 1 3938
-1 1 1 -1 -1 1 -1193
1 -1 1 1 1 1 1739
-1 1 1 -1 1 -1 4977
1 -1 -1 1 1 -1 -4624
-1 1 -1 1 -1 -1 718
-1 -1 1 -1 -1 -1 -3181
1 1 -1 -1 -1 1 -3473
1 1 -1 -1 -1 -1 544
1 1 1 1 -1 -1 -677
1 1 -1 1 1 1 4701
-1 1 1 1 -1 -1 -4164
-1 -1 -1 1 1 1 -472
1 1 1 1 1 1 -35...

output:

impossible

result:

ok single line: 'impossible'

Test #13:

score: 0
Accepted
time: 65ms
memory: 23840kb

input:

50000
1 1 1 1 1 1 4994
1 -1 1 1 1 -1 4090
-1 -1 1 1 1 -1 1070
1 -1 1 -1 -1 1 2518
1 1 -1 -1 -1 1 -588
-1 -1 -1 1 1 -1 894
-1 1 1 1 1 1 -216
1 1 1 -1 1 1 -3055
1 -1 1 1 1 1 3376
1 1 -1 -1 1 1 -428
-1 1 1 1 -1 -1 -1420
-1 1 1 -1 1 1 4025
1 -1 -1 -1 1 1 3713
1 -1 1 1 -1 -1 -4496
-1 1 -1 -1 1 1 -790
1 1...

output:

impossible

result:

ok single line: 'impossible'

Test #14:

score: 0
Accepted
time: 8ms
memory: 8996kb

input:

10000
1000 1000 1000 1000 1000 1000 1000
-279 -71 970 583 -485 -256 -439
-459 303 -784 -636 -503 -560 -91
-947 923 329 -961 989 -118 -531
-659 -458 -523 -320 -425 963 -595
73 -868 -742 976 81 -595 216
332 -685 883 657 708 182 797
758 -395 672 -232 412 150 639
81 525 858 -888 843 -175 -819
-686 897 4...

output:

impossible

result:

ok single line: 'impossible'

Test #15:

score: 0
Accepted
time: 3ms
memory: 8964kb

input:

10000
1000 1000 1000 1000 1000 1000 1000
998 1000 -200 -901 622 941 -362
-608 -330 366 544 -341 -428 -318
-302 435 -114 -233 -777 -735 -295
-421 896 -424 606 -33 -496 -601
245 -41 -535 747 -330 443 -365
-289 643 -866 -976 325 -49 99
-186 127 189 100 528 257 -574
-780 -955 -241 -568 -800 -722 663
-37...

output:

impossible

result:

ok single line: 'impossible'

Test #16:

score: 0
Accepted
time: 91ms
memory: 24972kb

input:

50000
1000 1000 1000 1000 1000 1000 1000
-305 862 -527 463 -204 199 -158
805 -733 614 528 996 917 316
-273 -334 -698 862 -811 49 432
159 99 822 906 485 -881 402
-820 373 -462 -111 -869 684 -609
-480 -112 842 -370 900 683 -429
-653 472 -620 -200 -85 -490 -709
-964 -310 740 491 28 710 -972
-811 -617 -...

output:

impossible

result:

ok single line: 'impossible'

Test #17:

score: 0
Accepted
time: 133ms
memory: 31992kb

input:

50000
10000 10000 10000 10000 10000 10000 10000
6033 4235 8203 7263 -4695 -801 -2308
7461 2512 -9858 -2039 -2807 -8160 9562
-5427 -9345 -3202 -324 -1624 -9303 6654
-2998 3627 3038 5527 9830 -6543 -2317
-3632 9282 7248 -8264 7907 -5347 3574
-8529 -8453 7626 -8725 -5318 -3811 -5914
-4216 -8639 8663 25...

output:

impossible

result:

ok single line: 'impossible'

Test #18:

score: 0
Accepted
time: 124ms
memory: 31988kb

input:

50000
10000 10000 10000 10000 10000 10000 10000
-6529 -348 3680 3690 -2720 -8171 -6717
-535 -373 2263 -4067 303 9944 -5267
-6959 -1454 557 -443 -3818 6226 -6972
-3941 -5436 -7139 4971 6426 -5649 -8255
1805 -2129 5339 651 -9840 -4942 -2774
-8623 2367 -773 -9162 2835 3571 -782
-3902 -8742 9320 4626 -8...

output:

impossible

result:

ok single line: 'impossible'

Test #19:

score: 0
Accepted
time: 0ms
memory: 4696kb

input:

1000
500 20 20 500 500 500 10
-54 -10 8 -82 -205 500 2
320 8 -9 133 50 415 -6
-311 3 8 -404 -451 -293 2
-249 20 -14 314 90 154 3
406 9 -14 274 -352 277 10
-197 20 11 57 -445 248 3
-357 -5 -16 -407 -499 415 -2
-89 14 6 -240 -464 344 2
-395 -15 -17 135 421 47 3
425 -15 18 -32 388 65 -4
144 20 -7 373 -...

output:

possible

result:

ok single line: 'possible'

Test #20:

score: 0
Accepted
time: 4ms
memory: 4764kb

input:

1000
500 20 20 500 500 500 10
-137 -8 -6 254 69 65 -9
467 -5 19 436 -293 -264 1
-191 -4 -6 -500 184 428 -3
13 -3 1 -464 -495 170 9
109 -6 -16 42 200 313 6
310 -13 -17 349 -440 -328 4
-63 2 -17 356 183 306 -3
166 12 -5 -331 488 303 4
458 7 -14 -213 349 324 -9
-124 -20 -15 19 -153 413 5
168 1 -8 166 -...

output:

possible

result:

ok single line: 'possible'

Test #21:

score: 0
Accepted
time: 77ms
memory: 21820kb

input:

40000
5000 5000 5000 5000 5000 5000 5000
-4893 1892 2422 4622 4524 4363 -4142
466 2253 978 -3262 3229 108 -1053
499 4634 383 3075 2233 4548 -2178
3690 3227 3851 3581 -2395 -3853 -425
1586 2557 -4469 1866 -1656 594 -1014
4824 -1607 -73 3522 4001 -2867 3505
2127 -2402 -677 2719 -1120 989 2882
3900 172...

output:

possible

result:

ok single line: 'possible'

Test #22:

score: 0
Accepted
time: 50ms
memory: 23820kb

input:

50000
1 1 1 1 1 1 4994
1 1 -1 1 1 1 -1176
1 1 1 1 -1 1 4914
1 1 1 1 1 -1 1154
-1 1 1 1 1 1 -1948
-1 1 1 1 1 1 -835
1 1 1 1 -1 1 866
1 -1 1 1 1 1 2221
1 -1 1 1 1 1 1113
1 1 1 -1 1 1 378
1 1 1 1 1 1 754
1 1 1 1 1 1 3372
1 -1 1 1 1 1 3415
1 1 1 1 1 -1 1287
1 1 1 1 1 1 -2395
1 1 1 1 1 1 -4023
1 1 1 -1 1...

output:

possible

result:

ok single line: 'possible'

Test #23:

score: 0
Accepted
time: 56ms
memory: 23828kb

input:

50000
1 1 1 1 1 1 4994
1 1 -1 1 1 1 312
1 1 1 1 1 -1 3329
1 1 1 1 1 1 -1972
1 1 1 1 1 1 1627
1 1 1 1 -1 1 -2669
1 1 1 1 1 1 -1481
1 -1 1 1 1 1 -1933
1 1 1 1 1 1 2874
1 1 1 1 1 -1 -3358
-1 1 1 1 1 1 -4658
1 1 1 1 1 1 2594
1 1 -1 1 1 1 -2721
1 1 1 1 1 -1 -1636
1 1 1 1 -1 1 -2193
1 1 -1 1 1 1 4232
1 1 ...

output:

possible

result:

ok single line: 'possible'

Test #24:

score: 0
Accepted
time: 10ms
memory: 8496kb

input:

10000
1000 1000 1000 1000 1000 1000 1000
-980 -599 793 -876 482 135 -236
491 -316 624 216 767 368 297
-382 -313 -995 231 -776 -180 395
888 131 186 916 484 -26 899
329 524 494 -203 63 35 -231
549 -885 587 785 -294 -391 8
-272 515 -215 -215 45 -986 710
530 379 746 -405 -779 429 587
-308 -54 72 -368 -2...

output:

possible

result:

ok single line: 'possible'

Test #25:

score: 0
Accepted
time: 13ms
memory: 8400kb

input:

10000
1000 1000 1000 1000 1000 1000 1000
735 -241 193 811 -849 -939 574
278 441 -55 -297 670 -962 -736
-292 -337 635 829 24 83 -398
-558 738 -857 -350 -335 -396 420
-883 -836 519 382 -155 67 -611
479 700 104 126 880 -164 -93
-923 -302 -721 -434 581 992 -792
89 -359 -91 18 737 72 924
-91 876 454 -96 ...

output:

possible

result:

ok single line: 'possible'

Test #26:

score: 0
Accepted
time: 96ms
memory: 24404kb

input:

50000
1000 1000 1000 1000 1000 1000 1000
-210 -637 -580 -718 963 869 -504
291 -413 854 149 907 787 877
-627 -503 -22 -162 -748 385 -451
825 864 -373 -652 -445 110 -50
-403 452 481 666 -437 960 -819
-532 200 867 -582 824 463 86
296 -979 227 472 -314 -925 -556
96 892 158 899 -759 -938 442
-227 973 855...

output:

possible

result:

ok single line: 'possible'

Test #27:

score: 0
Accepted
time: 101ms
memory: 26984kb

input:

50000
10000 10000 10000 10000 10000 10000 10000
7609 -179 -9580 -833 6450 8118 8678
2291 2666 8828 8551 -7811 2981 -3673
1283 -1304 -4355 -3583 7620 -2662 8961
8685 4966 527 2502 2186 -6466 -9008
2264 -2613 1111 7901 -7860 4890 -8755
-5050 1843 4794 3092 -3203 -3789 7703
7739 -1256 9650 -5023 -7033 ...

output:

possible

result:

ok single line: 'possible'

Test #28:

score: 0
Accepted
time: 129ms
memory: 26864kb

input:

50000
10000 10000 10000 10000 10000 10000 10000
3986 -3862 7759 -8718 7314 2910 -636
6646 9909 3091 -7731 -3490 9620 -9659
4841 -8674 -4827 -6804 4302 -1915 -5638
-9307 4332 -2457 6013 -1670 6815 -9194
2690 3526 -2657 6787 -8759 -6658 -5441
-1813 526 8450 -5920 8097 9944 -8841
-9299 7151 4117 2383 -...

output:

possible

result:

ok single line: 'possible'

Test #29:

score: 0
Accepted
time: 76ms
memory: 23932kb

input:

50000
10 10 10 10 10 10 10
-2 4 2 2 6 -8 6
-2 5 -3 8 8 -10 -3
8 -4 -1 -10 5 -6 4
10 -3 -7 -10 1 -9 9
-7 3 -9 6 -9 5 1
-9 -3 -1 6 -5 10 8
5 8 -3 5 10 10 -5
4 3 -8 10 4 -5 -5
-1 -4 -3 -9 6 -4 10
4 -3 -1 -7 6 2 4
9 -1 10 -6 6 1 1
-2 5 3 9 2 -7 3
5 10 -2 5 6 1 -7
4 -8 4 4 -7 6 -1
3 -7 -4 5 -3 -7 -4
-6 7...

output:

impossible

result:

ok single line: 'impossible'

Test #30:

score: 0
Accepted
time: 0ms
memory: 4240kb

input:

3
3 3 3 3 3 3 3
3 1 2 1 3 1 2
-2 -1 2 3 -1 3 2
2 3 1 2 3 -1 2
3 2

output:

impossible

result:

ok single line: 'impossible'