File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,20 @@ void solve(){
4747 vector<int > timep (N,-1 );
4848 int not_vis = N;
4949 if (M > N) M = N;
50+
51+ vector<bool > vis (2 *N,false );
52+
53+ set<int > unseen;
54+ for (int i=0 ; i< gg.size () ; ++i)unseen.insert (i);
5055 for (int time = M ; time >= 0 && not_vis>0 ; --time)
5156 {
52- for (int i=0 ; i< gg.size () ; ++i){
57+ vector<int >del;
58+ for (auto i : unseen){
59+ int status = (gg[i].cur << 1 ) + (gg[i].dir ==1 );
60+ if (vis[status]){
61+ del.push_back (i);
62+ continue ;
63+ }else vis[status] =true ;
5364 int & cur = gg[i].cur ;
5465 if (timep[cur]<time){
5566 not_vis--;
@@ -60,6 +71,7 @@ void solve(){
6071 }
6172 gg[i].cur = (cur + gg[i].dir + N) % N;
6273 }
74+ for (auto e : del)unseen.erase (e);
6375 }
6476 vector<int > ans (G);
6577 for (auto e: gg){
You can’t perform that action at this time.
0 commit comments