Submission #1069945

# Submission time Handle Problem Language Result Execution time Memory
1069945 2024-08-22T10:25:00 Z new_acc Toy Train (IOI17_train) C++14
100 / 100
1038 ms 6488 KB
#include "train.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
const int N=1e5+10;
int t[N],t2[N],n,m,il[N];
vi graf[N],graf2[N];
bool byl[N];
vi who_wins(vi a,vi r,vi u,vi v) {
    n=a.size(),m=u.size();
    vi res(n,1);
    for(int i=1;i<=n;i++) t[i]=a[i-1],t2[i]=r[i-1];
    for(int i=1;i<=m;i++){
        graf[u[i-1]+1].push_back(v[i-1]+1);
        graf2[v[i-1]+1].push_back(u[i-1]+1);
    }
    for(int i2=0;i2<n;i2++){
    for(int i=1;i<=n;i++) il[i]=graf[i].size();
    vi curr; 
    for(int i=1;i<=n;i++){
        if(t2[i] and res[i-1]) curr.push_back(i),byl[i]=1;
        else byl[i]=0;
    }
    for(int i=0;i<curr.size();i++){
        int x=curr[i];
        for(auto u:graf2[x]){
            if(t[u]){
                if(!byl[u]) curr.push_back(u);
                byl[u]=1;
            }else{
                il[u]--;
                if(il[u]==0 and !byl[u]){
                    byl[u]=1;
                    curr.push_back(u);
                }
            }
        }
    }
    curr.clear();
    for(int i=1;i<=n;i++){
        if(!byl[i]){
            curr.push_back(i);
            byl[i]=1;
        }else byl[i]=0;
        il[i]=graf[i].size();
    }
    for(int i=0;i<curr.size();i++){
        int x=curr[i];
        res[x-1]=0;
        for(auto u:graf2[x]){
            if(!t[u]){
                if(!byl[u]){
                    byl[u]=1;
                    curr.push_back(u);
                }
            }else{
                il[u]--;
                if(il[u]==0 and !byl[u]){
                    byl[u]=1;
                    curr.push_back(u);
                }
            }
        }
    }
    }
    return res;
}

Compilation message

train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<curr.size();i++){
      |                 ~^~~~~~~~~~~~
train.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0;i<curr.size();i++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 308 ms 5720 KB Output is correct
2 Correct 285 ms 5844 KB Output is correct
3 Correct 300 ms 5844 KB Output is correct
4 Correct 290 ms 5720 KB Output is correct
5 Correct 376 ms 5968 KB Output is correct
6 Correct 292 ms 5720 KB Output is correct
7 Correct 321 ms 5972 KB Output is correct
8 Correct 343 ms 5848 KB Output is correct
9 Correct 284 ms 5720 KB Output is correct
10 Correct 281 ms 5780 KB Output is correct
11 Correct 377 ms 5780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5208 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 1 ms 4956 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 439 ms 6236 KB Output is correct
2 Correct 453 ms 6236 KB Output is correct
3 Correct 489 ms 6236 KB Output is correct
4 Correct 595 ms 6236 KB Output is correct
5 Correct 725 ms 6236 KB Output is correct
6 Correct 590 ms 6284 KB Output is correct
7 Correct 678 ms 6236 KB Output is correct
8 Correct 853 ms 6208 KB Output is correct
9 Correct 568 ms 6248 KB Output is correct
10 Correct 858 ms 6232 KB Output is correct
11 Correct 887 ms 6188 KB Output is correct
12 Correct 615 ms 5976 KB Output is correct
13 Correct 718 ms 6296 KB Output is correct
14 Correct 669 ms 6296 KB Output is correct
15 Correct 669 ms 6236 KB Output is correct
16 Correct 663 ms 6480 KB Output is correct
17 Correct 680 ms 6292 KB Output is correct
18 Correct 380 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 408 ms 5980 KB Output is correct
2 Correct 393 ms 5932 KB Output is correct
3 Correct 492 ms 6232 KB Output is correct
4 Correct 507 ms 6156 KB Output is correct
5 Correct 571 ms 6236 KB Output is correct
6 Correct 693 ms 6232 KB Output is correct
7 Correct 758 ms 6236 KB Output is correct
8 Correct 498 ms 6236 KB Output is correct
9 Correct 537 ms 5976 KB Output is correct
10 Correct 461 ms 6236 KB Output is correct
11 Correct 479 ms 6288 KB Output is correct
12 Correct 472 ms 6232 KB Output is correct
13 Correct 499 ms 6256 KB Output is correct
14 Correct 559 ms 6168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 714 ms 6256 KB Output is correct
2 Correct 523 ms 6236 KB Output is correct
3 Correct 1038 ms 6236 KB Output is correct
4 Correct 477 ms 6180 KB Output is correct
5 Correct 2 ms 5208 KB Output is correct
6 Correct 319 ms 5804 KB Output is correct
7 Correct 26 ms 5724 KB Output is correct
8 Correct 46 ms 5976 KB Output is correct
9 Correct 36 ms 5720 KB Output is correct
10 Correct 4 ms 5212 KB Output is correct
11 Correct 25 ms 5648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 5720 KB Output is correct
2 Correct 285 ms 5844 KB Output is correct
3 Correct 300 ms 5844 KB Output is correct
4 Correct 290 ms 5720 KB Output is correct
5 Correct 376 ms 5968 KB Output is correct
6 Correct 292 ms 5720 KB Output is correct
7 Correct 321 ms 5972 KB Output is correct
8 Correct 343 ms 5848 KB Output is correct
9 Correct 284 ms 5720 KB Output is correct
10 Correct 281 ms 5780 KB Output is correct
11 Correct 377 ms 5780 KB Output is correct
12 Correct 1 ms 5208 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 1 ms 4956 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 1 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 1 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 1 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 439 ms 6236 KB Output is correct
33 Correct 453 ms 6236 KB Output is correct
34 Correct 489 ms 6236 KB Output is correct
35 Correct 595 ms 6236 KB Output is correct
36 Correct 725 ms 6236 KB Output is correct
37 Correct 590 ms 6284 KB Output is correct
38 Correct 678 ms 6236 KB Output is correct
39 Correct 853 ms 6208 KB Output is correct
40 Correct 568 ms 6248 KB Output is correct
41 Correct 858 ms 6232 KB Output is correct
42 Correct 887 ms 6188 KB Output is correct
43 Correct 615 ms 5976 KB Output is correct
44 Correct 718 ms 6296 KB Output is correct
45 Correct 669 ms 6296 KB Output is correct
46 Correct 669 ms 6236 KB Output is correct
47 Correct 663 ms 6480 KB Output is correct
48 Correct 680 ms 6292 KB Output is correct
49 Correct 380 ms 5724 KB Output is correct
50 Correct 408 ms 5980 KB Output is correct
51 Correct 393 ms 5932 KB Output is correct
52 Correct 492 ms 6232 KB Output is correct
53 Correct 507 ms 6156 KB Output is correct
54 Correct 571 ms 6236 KB Output is correct
55 Correct 693 ms 6232 KB Output is correct
56 Correct 758 ms 6236 KB Output is correct
57 Correct 498 ms 6236 KB Output is correct
58 Correct 537 ms 5976 KB Output is correct
59 Correct 461 ms 6236 KB Output is correct
60 Correct 479 ms 6288 KB Output is correct
61 Correct 472 ms 6232 KB Output is correct
62 Correct 499 ms 6256 KB Output is correct
63 Correct 559 ms 6168 KB Output is correct
64 Correct 714 ms 6256 KB Output is correct
65 Correct 523 ms 6236 KB Output is correct
66 Correct 1038 ms 6236 KB Output is correct
67 Correct 477 ms 6180 KB Output is correct
68 Correct 2 ms 5208 KB Output is correct
69 Correct 319 ms 5804 KB Output is correct
70 Correct 26 ms 5724 KB Output is correct
71 Correct 46 ms 5976 KB Output is correct
72 Correct 36 ms 5720 KB Output is correct
73 Correct 4 ms 5212 KB Output is correct
74 Correct 25 ms 5648 KB Output is correct
75 Correct 350 ms 6292 KB Output is correct
76 Correct 433 ms 6232 KB Output is correct
77 Correct 428 ms 6324 KB Output is correct
78 Correct 425 ms 6316 KB Output is correct
79 Correct 437 ms 6236 KB Output is correct
80 Correct 619 ms 6284 KB Output is correct
81 Correct 971 ms 6260 KB Output is correct
82 Correct 858 ms 6232 KB Output is correct
83 Correct 712 ms 6488 KB Output is correct
84 Correct 682 ms 6288 KB Output is correct
85 Correct 474 ms 6236 KB Output is correct
86 Correct 728 ms 6236 KB Output is correct
87 Correct 469 ms 6232 KB Output is correct
88 Correct 975 ms 6232 KB Output is correct
89 Correct 705 ms 6232 KB Output is correct
90 Correct 915 ms 6236 KB Output is correct
91 Correct 730 ms 6280 KB Output is correct
92 Correct 892 ms 6232 KB Output is correct
93 Correct 788 ms 6272 KB Output is correct
94 Correct 964 ms 6488 KB Output is correct
95 Correct 1020 ms 6284 KB Output is correct
96 Correct 519 ms 6196 KB Output is correct
97 Correct 875 ms 6288 KB Output is correct
98 Correct 996 ms 6488 KB Output is correct
99 Correct 950 ms 6232 KB Output is correct
100 Correct 402 ms 5720 KB Output is correct