답안 #974070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974070 2024-05-02T17:50:41 Z Ooops_sorry 길고양이 (JOI20_stray) C++14
15 / 100
43 ms 16560 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];

vector<int> res;

string s = "100110100110", rev_s = "011001011001";

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) {
        last = 0;
      } else {
        last = 1;
      }
      return last;
    }
    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] == 1) {
      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]) {
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 16244 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 24 ms 14980 KB Output is correct
4 Correct 39 ms 16436 KB Output is correct
5 Correct 37 ms 16560 KB Output is correct
6 Correct 27 ms 15404 KB Output is correct
7 Correct 26 ms 15544 KB Output is correct
8 Correct 33 ms 16240 KB Output is correct
9 Correct 36 ms 16184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 16244 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 24 ms 14980 KB Output is correct
4 Correct 39 ms 16436 KB Output is correct
5 Correct 37 ms 16560 KB Output is correct
6 Correct 27 ms 15404 KB Output is correct
7 Correct 26 ms 15544 KB Output is correct
8 Correct 33 ms 16240 KB Output is correct
9 Correct 36 ms 16184 KB Output is correct
10 Correct 32 ms 13688 KB Output is correct
11 Correct 27 ms 13680 KB Output is correct
12 Correct 26 ms 13880 KB Output is correct
13 Correct 26 ms 13516 KB Output is correct
14 Correct 39 ms 14172 KB Output is correct
15 Correct 31 ms 14196 KB Output is correct
16 Correct 34 ms 15908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13172 KB Output is correct
2 Correct 2 ms 1304 KB Output is correct
3 Correct 22 ms 12688 KB Output is correct
4 Correct 37 ms 14456 KB Output is correct
5 Correct 43 ms 14464 KB Output is correct
6 Correct 28 ms 13244 KB Output is correct
7 Correct 30 ms 13192 KB Output is correct
8 Correct 31 ms 13856 KB Output is correct
9 Correct 32 ms 13908 KB Output is correct
10 Correct 34 ms 13608 KB Output is correct
11 Correct 27 ms 13756 KB Output is correct
12 Correct 27 ms 13688 KB Output is correct
13 Correct 32 ms 13600 KB Output is correct
14 Correct 32 ms 13924 KB Output is correct
15 Correct 33 ms 14012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13172 KB Output is correct
2 Correct 2 ms 1304 KB Output is correct
3 Correct 22 ms 12688 KB Output is correct
4 Correct 37 ms 14456 KB Output is correct
5 Correct 43 ms 14464 KB Output is correct
6 Correct 28 ms 13244 KB Output is correct
7 Correct 30 ms 13192 KB Output is correct
8 Correct 31 ms 13856 KB Output is correct
9 Correct 32 ms 13908 KB Output is correct
10 Correct 34 ms 13608 KB Output is correct
11 Correct 27 ms 13756 KB Output is correct
12 Correct 27 ms 13688 KB Output is correct
13 Correct 32 ms 13600 KB Output is correct
14 Correct 32 ms 13924 KB Output is correct
15 Correct 33 ms 14012 KB Output is correct
16 Correct 24 ms 11636 KB Output is correct
17 Correct 23 ms 11656 KB Output is correct
18 Correct 27 ms 11660 KB Output is correct
19 Correct 32 ms 11536 KB Output is correct
20 Correct 27 ms 12396 KB Output is correct
21 Correct 30 ms 12140 KB Output is correct
22 Correct 28 ms 13760 KB Output is correct
23 Correct 26 ms 11896 KB Output is correct
24 Correct 26 ms 11684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1560 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 11380 KB Output is correct
2 Incorrect 24 ms 12536 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 11452 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -