Submission #923118

# Submission time Handle Problem Language Result Execution time Memory
923118 2024-02-06T17:07:33 Z huutuan Stray Cat (JOI20_stray) C++14
15 / 100
34 ms 21332 KB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

#ifndef sus
#define cerr if (0) cerr
#endif

const int N=2e4+10;

namespace sub1234{
   vector<int> g[N];
   vector<int> ans;
   int dep[N];
   void bfs(){
      memset(dep, -1, sizeof dep);
      queue<int> q;
      q.push(0); dep[0]=0;
      while (q.size()){
         int u=q.front(); q.pop();
         for (int v:g[u]){
            if (dep[v]==-1){
               dep[v]=dep[u]+1;
               q.push(v);
            }
         }
      }
   }
   vector<int> solve(int n, int m, vector<int> u, vector<int> v){
      ans.resize(m, -1);
      for (int i=0; i<m; ++i){
         g[u[i]].push_back(v[i]);
         g[v[i]].push_back(u[i]);
      }
      bfs();
      for (int i=0; i<m; ++i){
         ans[i]=min(dep[u[i]], dep[v[i]])%3;
         cerr << u[i] << ' ' << v[i] << ' ' << ans[i] << '\n';
      }
      return ans;
   }
}

namespace sub567{
   string sussy="011001";
   vector<int> path;
   vector<pair<int, int>> g[N];
   vector<int> ans;
   int par_idx[N];
   void dfs(int u, int p){
      pair<int, int> pp={-1, -1};
      for (auto &e:g[u]) if (e.first==p) pp=e;
      if (pp.first!=-1) g[u].erase(find(g[u].begin(), g[u].end(), pp));
      if ((int)g[u].size()==1){
         if (path.empty()) path.push_back(par_idx[u]);
         path.push_back(g[u][0].second);
         par_idx[g[u][0].first]=g[u][0].second;
         dfs(g[u][0].first, u);
      }else{
         if (path.size()){
            int first_edge=path[0]==-1?0:ans[path[0]]^1;
            path.erase(path.begin());
            for (int i=0; i<(int)path.size(); ++i) ans[path[i]]=sussy[(i+first_edge)%6]-'0';
         }
         path.clear();
         for (auto &e:g[u]){
            int v=e.first, i=e.second;
            ans[i]=par_idx[u]==-1?0:ans[par_idx[u]]^1;
            par_idx[v]=i;
            if ((int)g[v].size()==1){
               path.clear();
               path.push_back(par_idx[u]);
            }
            dfs(v, u);
         }
      }
   }
   vector<int> solve(int n, int m, vector<int> u, vector<int> v){
      ans.resize(m);
      par_idx[0]=-1;
      for (int i=0; i<m; ++i){
         g[u[i]].emplace_back(v[i], i);
         g[v[i]].emplace_back(u[i], i);
      }
      dfs(0, -1);
      for (int i=0; i<m; ++i) cerr << u[i] << ' ' << v[i] << ' ' << ans[i] << '\n';
      return ans;
   }
}

vector<int> Mark(int n, int m, int a, int b,
                 vector<int> u, vector<int> v) {
   if (a!=2){
      return sub1234::solve(n, m, u, v);
   }
   return sub567::solve(n, m, u, v);
}
#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

#ifndef sus
#define cerr if (0) cerr
#endif

int a, b;

void Init(int A, int B) {
   a=A;
   b=B;
}

vector<pair<int, int>> v;

string sussy="011001";

bool check_sus(){
   if ((int)v.size()<6) return 0;
   string lmao;
   for (int i=6; i>=1; --i){
      if (v.end()[-i].first!=1) return 0;
      lmao.push_back('0'+v.end()[-i].second);
   }
   for (int i=0; i<6; ++i){
      if (lmao==sussy) return 1;
      lmao.push_back(lmao[0]); lmao.erase(lmao.begin());
   }
   return 0;
}

int Move(vector<int> y) {
   if (a!=2){
      if (y[0] && y[1]) return 0;
      if (y[1] && y[2]) return 1;
      if (y[2] && y[0]) return 2;
      for (int i=0; i<3; ++i) if (y[i]) return i;
   }
   if (y[0]+y[1]==1){
      if (y[0]){
         v.emplace_back(1, 0);
         if (check_sus()){
            v.emplace_back(-1, -1);
            return -1;
         }
         return 0;
      }else{
         v.emplace_back(1, 1);
         if (check_sus()){
            v.emplace_back(-1, -1);
            return -1;
         }
         return 1;
      }
   }
   if (y[0]==1){
      v.emplace_back(0, 0);
      return 0;
   }
   if (y[1]==1){
      v.emplace_back(0, 1);
      return 1;
   }
   if (y[0]){
      v.emplace_back(0, 0);
      return 0;
   }
   if (y[1]){
      v.emplace_back(0, 1);
      return 1;
   }
   assert(false);
   return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 16596 KB Output is correct
2 Correct 1 ms 1812 KB Output is correct
3 Correct 25 ms 16436 KB Output is correct
4 Correct 33 ms 17704 KB Output is correct
5 Correct 34 ms 17744 KB Output is correct
6 Correct 27 ms 16456 KB Output is correct
7 Correct 27 ms 16544 KB Output is correct
8 Correct 31 ms 17140 KB Output is correct
9 Correct 31 ms 17228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 16596 KB Output is correct
2 Correct 1 ms 1812 KB Output is correct
3 Correct 25 ms 16436 KB Output is correct
4 Correct 33 ms 17704 KB Output is correct
5 Correct 34 ms 17744 KB Output is correct
6 Correct 27 ms 16456 KB Output is correct
7 Correct 27 ms 16544 KB Output is correct
8 Correct 31 ms 17140 KB Output is correct
9 Correct 31 ms 17228 KB Output is correct
10 Correct 25 ms 14656 KB Output is correct
11 Correct 26 ms 14668 KB Output is correct
12 Correct 25 ms 14664 KB Output is correct
13 Correct 25 ms 14700 KB Output is correct
14 Correct 26 ms 14872 KB Output is correct
15 Correct 30 ms 15180 KB Output is correct
16 Correct 31 ms 17236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 14136 KB Output is correct
2 Correct 1 ms 2356 KB Output is correct
3 Correct 23 ms 13536 KB Output is correct
4 Correct 33 ms 15656 KB Output is correct
5 Correct 31 ms 15672 KB Output is correct
6 Correct 27 ms 14160 KB Output is correct
7 Correct 26 ms 14296 KB Output is correct
8 Correct 28 ms 14880 KB Output is correct
9 Correct 28 ms 14924 KB Output is correct
10 Correct 27 ms 14688 KB Output is correct
11 Correct 27 ms 14616 KB Output is correct
12 Correct 27 ms 14664 KB Output is correct
13 Correct 27 ms 14668 KB Output is correct
14 Correct 32 ms 14796 KB Output is correct
15 Correct 28 ms 14760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 14136 KB Output is correct
2 Correct 1 ms 2356 KB Output is correct
3 Correct 23 ms 13536 KB Output is correct
4 Correct 33 ms 15656 KB Output is correct
5 Correct 31 ms 15672 KB Output is correct
6 Correct 27 ms 14160 KB Output is correct
7 Correct 26 ms 14296 KB Output is correct
8 Correct 28 ms 14880 KB Output is correct
9 Correct 28 ms 14924 KB Output is correct
10 Correct 27 ms 14688 KB Output is correct
11 Correct 27 ms 14616 KB Output is correct
12 Correct 27 ms 14664 KB Output is correct
13 Correct 27 ms 14668 KB Output is correct
14 Correct 32 ms 14796 KB Output is correct
15 Correct 28 ms 14760 KB Output is correct
16 Correct 23 ms 12600 KB Output is correct
17 Correct 26 ms 12748 KB Output is correct
18 Correct 24 ms 12700 KB Output is correct
19 Correct 24 ms 12608 KB Output is correct
20 Correct 26 ms 13372 KB Output is correct
21 Correct 25 ms 13108 KB Output is correct
22 Correct 28 ms 15180 KB Output is correct
23 Correct 27 ms 12864 KB Output is correct
24 Correct 27 ms 12676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 2332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 21040 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 21332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -