Submission #974069

# Submission time Handle Problem Language Result Execution time Memory
974069 2024-05-02T17:45:22 Z Ooops_sorry Stray Cat (JOI20_stray) C++14
15 / 100
41 ms 17064 KB
#ifndef LOCAL
  #include "Anthony.h"
#endif 
#include<iostream>
#include<deque>
#include<algorithm>
#include<vector>
#include<map>
#include<random>
#include<time.h>
#include<cassert>
#include<chrono>
#include<set>
#include<unordered_set>
#include<array>
 
using namespace std;
 
#define ull unsigned long long
#define pb push_back
#define ll long long
#define all(a) a.begin(), a.end()
#define ld long double 
 
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const int N = 2e4 + 10;
vector<pair<int, int>> g[N];
 
string s = "100110100110", rev_s = "011001011001";
 
vector<int> res;
 
void dfs(int v, int p, int pos) {
  if (v == 0) {
    for (auto [u, i] : g[v]) {
      res[i] = 1;
      dfs(u, v, 1);
    } 
  } else {
    int last = s[pos + 5] - '0';
    if (g[v].size() >= 3) {
      for (auto [u, i] : g[v]) {
        if (u != p) {
          res[i] = last ^ 1;
          dfs(u, v, last ^ 1);
        }
      }
    } else {
      for (auto [u, i] : g[v]) {
        if (u != p) {
          res[i] = s[pos] - '0';
          dfs(u, v, (pos + 1) % 6);
        }
      }
    }
  }
}
 
vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v) {
  for (int i = 0; i < m; i++) {
    g[u[i]].pb({v[i], i});
    g[v[i]].pb({u[i], i});
  }
  if (a >= 3) {
    vector<int> d(n, -1);
    d[0] = 0;
    deque<int> q{0};
    while (q.size() > 0) {
      int v = q.front();
      q.pop_front();
      for (auto [u, i] : g[v]) {
        if (d[u] == -1) {
          d[u] = d[v] + 1;
          q.pb(u);
        }
      }
    }
    vector<int> ans(m, -1);
    for (int v = 0; v < n; v++) {
      for (auto [u, i] : g[v]) {
        if (d[u] == d[v]) {
          ans[i] = d[u] % 3;
        } else {
          ans[i] = min(d[u], d[v]) % 3;
        }
      }
    }
    return ans;
  } else {
    res.resize(m, -1);
    dfs(0, -1, -1);
    return res;
  }
}
#ifndef LOCAL
  #include "Catherine.h"
#endif 
#include<iostream>
#include<deque>
#include<algorithm>
#include<vector>
#include<map>
#include<random>
#include<time.h>
#include<cassert>
#include<chrono>
#include<set>
#include<unordered_set>
#include<array>
 
using namespace std;
 
#define ull unsigned long long
#define pb push_back
#define ll long long
#define all(a) a.begin(), a.end()
#define ld long double 
 
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
 
int A, B;
 
void Init(int A_, int B_) {
  A = A_;
  B = B_;
}
 
string kek = "";
bool top = 0;
int last = -1;

string s = "100110100110", rev_s = "011001011001";
 
bool in(string s, string t) {
  for (int i = 0; i + t.size() <= s.size(); i++) {
    if (s.substr(i, (int)t.size()) == t) {
      return 1;
    }
  }
  return 0;
}
 
int Move(std::vector<int> y) {
  if (A >= 3) {
    for (int i = 0; i < 3; i++) {
      if (y[i] > 0 && y[(i + 1) % 3] > 0) {
        return i;
      }
    }
    for (int i = 0; i < 3; i++) {
      if (y[i] > 0) {
        return i;
      }
    }
  } else {
    vector<int> y_new = y;
    if (last != -1) {
      y_new[last]++;
    }
    if (y_new[0] + y_new[1] > 2) {
      if (y_new[0] == 1) {
        last = 0;
      } else {
        last = 1;
      }
      top = 1;
      return last;
    }
    if (top) {
      if (y[0] > 0) return 0;
      return 1;
    }
    if (y[0] + y[1] == 2) {
      if (y[0] > 0 && y[1] > 0) {
        kek += "01";
        last = 1;
        return last;
      } else if (y[0] > 0) {
        kek += "00";
        last = 0;
        return last;
      } else {
        kek += "11";
        last = 1;
        return last;
      }
    } else if (y[0] + y[1] == 2) {
      if (y[0] > 0) {
        kek += "0";
      } else {
        kek += "1";
      }
      if (in(s, kek) && !in(rev_s, kek)) {
        top = 1;
        return -1;
      } else if (!in(s, kek) && in(rev_s, kek)) {
        top = 1;
        last = kek.back() - '0';
        return last;
      } else {
        last = kek.back() - '0';
        return last;
      }
    } else {
      top = 1;
      return -1;
    }
  }
  assert(0);
}

Compilation message

Anthony.cpp: In function 'void dfs(int, int, int)':
Anthony.cpp:36:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |     for (auto [u, i] : g[v]) {
      |               ^
Anthony.cpp:43:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |       for (auto [u, i] : g[v]) {
      |                 ^
Anthony.cpp:50:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |       for (auto [u, i] : g[v]) {
      |                 ^
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:72:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   72 |       for (auto [u, i] : g[v]) {
      |                 ^
Anthony.cpp:81:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   81 |       for (auto [u, i] : g[v]) {
      |                 ^
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15668 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 23 ms 15392 KB Output is correct
4 Correct 34 ms 17064 KB Output is correct
5 Correct 41 ms 17000 KB Output is correct
6 Correct 27 ms 15856 KB Output is correct
7 Correct 27 ms 15964 KB Output is correct
8 Correct 31 ms 16264 KB Output is correct
9 Correct 33 ms 16352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15668 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 23 ms 15392 KB Output is correct
4 Correct 34 ms 17064 KB Output is correct
5 Correct 41 ms 17000 KB Output is correct
6 Correct 27 ms 15856 KB Output is correct
7 Correct 27 ms 15964 KB Output is correct
8 Correct 31 ms 16264 KB Output is correct
9 Correct 33 ms 16352 KB Output is correct
10 Correct 26 ms 13800 KB Output is correct
11 Correct 26 ms 13868 KB Output is correct
12 Correct 27 ms 13692 KB Output is correct
13 Correct 25 ms 13808 KB Output is correct
14 Correct 27 ms 14084 KB Output is correct
15 Correct 30 ms 14424 KB Output is correct
16 Correct 31 ms 16336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 13188 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 22 ms 12760 KB Output is correct
4 Correct 33 ms 14464 KB Output is correct
5 Correct 31 ms 14460 KB Output is correct
6 Correct 27 ms 13312 KB Output is correct
7 Correct 27 ms 13156 KB Output is correct
8 Correct 36 ms 13932 KB Output is correct
9 Correct 34 ms 13788 KB Output is correct
10 Correct 31 ms 13680 KB Output is correct
11 Correct 28 ms 14188 KB Output is correct
12 Correct 26 ms 13684 KB Output is correct
13 Correct 27 ms 13688 KB Output is correct
14 Correct 30 ms 13940 KB Output is correct
15 Correct 28 ms 13944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 13188 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 22 ms 12760 KB Output is correct
4 Correct 33 ms 14464 KB Output is correct
5 Correct 31 ms 14460 KB Output is correct
6 Correct 27 ms 13312 KB Output is correct
7 Correct 27 ms 13156 KB Output is correct
8 Correct 36 ms 13932 KB Output is correct
9 Correct 34 ms 13788 KB Output is correct
10 Correct 31 ms 13680 KB Output is correct
11 Correct 28 ms 14188 KB Output is correct
12 Correct 26 ms 13684 KB Output is correct
13 Correct 27 ms 13688 KB Output is correct
14 Correct 30 ms 13940 KB Output is correct
15 Correct 28 ms 13944 KB Output is correct
16 Correct 23 ms 11624 KB Output is correct
17 Correct 24 ms 11640 KB Output is correct
18 Correct 24 ms 11868 KB Output is correct
19 Correct 25 ms 11772 KB Output is correct
20 Correct 30 ms 12308 KB Output is correct
21 Correct 27 ms 11964 KB Output is correct
22 Correct 27 ms 13952 KB Output is correct
23 Correct 25 ms 11888 KB Output is correct
24 Correct 25 ms 11896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1564 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 11276 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 11384 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -