답안 #1040468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040468 2024-08-01T05:27:35 Z boyliguanhan 장난감 기차 (IOI17_train) C++17
100 / 100
1130 ms 3944 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
set<int>radj[5010],adj[5010];
set<int>inv(vector<int>v,set<int>st){
    for(auto i:v)
        st.erase(i);
    return st;
}
vector<int>aset(set<int>v,vector<int>own){
    vector<int>cnt(5000),don(5000);
    queue<int>q;
    vector<int>ans;
    for(auto i:v)
        q.push(i),don[i]=1;
    while(q.size()){
        int x=q.front(); q.pop();
        ans.push_back(x);
        for(auto i:radj[x]) {
            if(don[i])continue;
            if(own[i]) q.push(i),don[i]=1;
            else if(++cnt[i]==adj[i].size())
                q.push(i),don[i]=1;
        }
    }
    return ans;
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
    int N=a.size(),M=u.size();
	std::vector<int> res(a.size()),bozo=a;
    for(auto&i:bozo)i=!i;
    for(int i=0;i<M;i++)
        adj[u[i]].insert(v[i]),
        radj[v[i]].insert(u[i]);
    set<int>charg,hav;
    for(int i=0;i<N;hav.insert(i++))
        if(r[i])charg.insert(i);
    int CC=N;
    while(CC) {
        vector<int>v=aset(charg,a);
        if(v.size()==CC){
            for(auto i:v)
                res[i]=1;
            break;
        }
        v=aset(inv(v,hav),bozo);
        for(auto i:v){ CC--;
            charg.erase(i);
            hav.erase(i);
            for(auto j:adj[i])
                radj[j].erase(i);
            for(auto j:radj[i])
                adj[j].erase(i);
            adj[i].clear();
            radj[i].clear();
        }
    }
	return res;
}

Compilation message

train.cpp: In function 'std::vector<int> aset(std::set<int>, std::vector<int>)':
train.cpp:22:29: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             else if(++cnt[i]==adj[i].size())
      |                     ~~~~~~~~^~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:41:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |         if(v.size()==CC){
      |            ~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2396 KB Output is correct
2 Correct 7 ms 2468 KB Output is correct
3 Correct 7 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 6 ms 2396 KB Output is correct
6 Correct 6 ms 2396 KB Output is correct
7 Correct 5 ms 2396 KB Output is correct
8 Correct 7 ms 2408 KB Output is correct
9 Correct 6 ms 2392 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 4 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 860 KB Output is correct
2 Correct 0 ms 860 KB Output is correct
3 Correct 0 ms 860 KB Output is correct
4 Correct 0 ms 860 KB Output is correct
5 Correct 0 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 0 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 0 ms 860 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 1 ms 864 KB Output is correct
18 Correct 0 ms 864 KB Output is correct
19 Correct 0 ms 868 KB Output is correct
20 Correct 0 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 360 ms 3680 KB Output is correct
2 Correct 628 ms 3780 KB Output is correct
3 Correct 738 ms 3672 KB Output is correct
4 Correct 9 ms 3672 KB Output is correct
5 Correct 11 ms 3672 KB Output is correct
6 Correct 12 ms 3672 KB Output is correct
7 Correct 8 ms 3724 KB Output is correct
8 Correct 10 ms 3676 KB Output is correct
9 Correct 10 ms 3620 KB Output is correct
10 Correct 10 ms 3420 KB Output is correct
11 Correct 9 ms 3416 KB Output is correct
12 Correct 8 ms 3416 KB Output is correct
13 Correct 8 ms 3420 KB Output is correct
14 Correct 7 ms 3420 KB Output is correct
15 Correct 8 ms 3420 KB Output is correct
16 Correct 9 ms 3576 KB Output is correct
17 Correct 7 ms 3420 KB Output is correct
18 Correct 989 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3416 KB Output is correct
2 Correct 8 ms 3420 KB Output is correct
3 Correct 10 ms 3804 KB Output is correct
4 Correct 11 ms 3944 KB Output is correct
5 Correct 11 ms 3676 KB Output is correct
6 Correct 10 ms 3488 KB Output is correct
7 Correct 9 ms 3676 KB Output is correct
8 Correct 10 ms 3712 KB Output is correct
9 Correct 9 ms 3672 KB Output is correct
10 Correct 8 ms 3932 KB Output is correct
11 Correct 8 ms 3916 KB Output is correct
12 Correct 7 ms 3932 KB Output is correct
13 Correct 10 ms 3584 KB Output is correct
14 Correct 9 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3804 KB Output is correct
2 Correct 8 ms 3420 KB Output is correct
3 Correct 9 ms 3624 KB Output is correct
4 Correct 7 ms 3168 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 4 ms 2144 KB Output is correct
7 Correct 8 ms 2976 KB Output is correct
8 Correct 10 ms 3164 KB Output is correct
9 Correct 9 ms 2908 KB Output is correct
10 Correct 2 ms 1372 KB Output is correct
11 Correct 7 ms 2868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2396 KB Output is correct
2 Correct 7 ms 2468 KB Output is correct
3 Correct 7 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 6 ms 2396 KB Output is correct
6 Correct 6 ms 2396 KB Output is correct
7 Correct 5 ms 2396 KB Output is correct
8 Correct 7 ms 2408 KB Output is correct
9 Correct 6 ms 2392 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 4 ms 2136 KB Output is correct
12 Correct 0 ms 860 KB Output is correct
13 Correct 0 ms 860 KB Output is correct
14 Correct 0 ms 860 KB Output is correct
15 Correct 0 ms 860 KB Output is correct
16 Correct 0 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 0 ms 860 KB Output is correct
20 Correct 0 ms 860 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 0 ms 860 KB Output is correct
24 Correct 0 ms 860 KB Output is correct
25 Correct 0 ms 860 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 0 ms 860 KB Output is correct
28 Correct 1 ms 864 KB Output is correct
29 Correct 0 ms 864 KB Output is correct
30 Correct 0 ms 868 KB Output is correct
31 Correct 0 ms 868 KB Output is correct
32 Correct 360 ms 3680 KB Output is correct
33 Correct 628 ms 3780 KB Output is correct
34 Correct 738 ms 3672 KB Output is correct
35 Correct 9 ms 3672 KB Output is correct
36 Correct 11 ms 3672 KB Output is correct
37 Correct 12 ms 3672 KB Output is correct
38 Correct 8 ms 3724 KB Output is correct
39 Correct 10 ms 3676 KB Output is correct
40 Correct 10 ms 3620 KB Output is correct
41 Correct 10 ms 3420 KB Output is correct
42 Correct 9 ms 3416 KB Output is correct
43 Correct 8 ms 3416 KB Output is correct
44 Correct 8 ms 3420 KB Output is correct
45 Correct 7 ms 3420 KB Output is correct
46 Correct 8 ms 3420 KB Output is correct
47 Correct 9 ms 3576 KB Output is correct
48 Correct 7 ms 3420 KB Output is correct
49 Correct 989 ms 2652 KB Output is correct
50 Correct 9 ms 3416 KB Output is correct
51 Correct 8 ms 3420 KB Output is correct
52 Correct 10 ms 3804 KB Output is correct
53 Correct 11 ms 3944 KB Output is correct
54 Correct 11 ms 3676 KB Output is correct
55 Correct 10 ms 3488 KB Output is correct
56 Correct 9 ms 3676 KB Output is correct
57 Correct 10 ms 3712 KB Output is correct
58 Correct 9 ms 3672 KB Output is correct
59 Correct 8 ms 3932 KB Output is correct
60 Correct 8 ms 3916 KB Output is correct
61 Correct 7 ms 3932 KB Output is correct
62 Correct 10 ms 3584 KB Output is correct
63 Correct 9 ms 3416 KB Output is correct
64 Correct 9 ms 3804 KB Output is correct
65 Correct 8 ms 3420 KB Output is correct
66 Correct 9 ms 3624 KB Output is correct
67 Correct 7 ms 3168 KB Output is correct
68 Correct 1 ms 1116 KB Output is correct
69 Correct 4 ms 2144 KB Output is correct
70 Correct 8 ms 2976 KB Output is correct
71 Correct 10 ms 3164 KB Output is correct
72 Correct 9 ms 2908 KB Output is correct
73 Correct 2 ms 1372 KB Output is correct
74 Correct 7 ms 2868 KB Output is correct
75 Correct 339 ms 3784 KB Output is correct
76 Correct 645 ms 3672 KB Output is correct
77 Correct 800 ms 3812 KB Output is correct
78 Correct 789 ms 3672 KB Output is correct
79 Correct 783 ms 3676 KB Output is correct
80 Correct 9 ms 3676 KB Output is correct
81 Correct 10 ms 3824 KB Output is correct
82 Correct 11 ms 3672 KB Output is correct
83 Correct 10 ms 3676 KB Output is correct
84 Correct 12 ms 3676 KB Output is correct
85 Correct 11 ms 3676 KB Output is correct
86 Correct 12 ms 3676 KB Output is correct
87 Correct 12 ms 3676 KB Output is correct
88 Correct 16 ms 3676 KB Output is correct
89 Correct 13 ms 3676 KB Output is correct
90 Correct 27 ms 3808 KB Output is correct
91 Correct 21 ms 3776 KB Output is correct
92 Correct 42 ms 3676 KB Output is correct
93 Correct 51 ms 3676 KB Output is correct
94 Correct 43 ms 3672 KB Output is correct
95 Correct 43 ms 3672 KB Output is correct
96 Correct 184 ms 3536 KB Output is correct
97 Correct 691 ms 3672 KB Output is correct
98 Correct 1044 ms 3748 KB Output is correct
99 Correct 1130 ms 3676 KB Output is correct
100 Correct 968 ms 2652 KB Output is correct