Codeforces Round # 589 (Div. 2) after the game to reflect

Reflection

In conclusion: think twice , never give up

Before the game ready

  1. Parse-tool not just for the familiar, the game time because the problem is set out pot

  2. This draft did not adjust, desktop layout, etc.

  3. It should be appropriate rest before the exam, but keep thinking sensitivity

Race

  1. A problem is relatively simple, but at the time I thought clearly began to write, and later found out that my flag is set backwards

  2. I listed on the draft of this situation B title is not established, but in the back of the derivation hemp certificate does not hold is the follow-up to determine to screen out, so the time to write did not write this part, the idea is not very clear on the cause of back thinking included waste a lot of time, after WA a has checked the code reasons, not to think the idea is not yet a problem, because I do not know how to operate, when a certain adjustment to h, w directly engage in counter, check and adjust the input spent 20 minutes direct mind explosion

  3. Problem C is abundantly clear, however, I first fast power pan after pan is quickly multiply and, finally, the accuracy of the problem, then the answer has been, and do not

  4. D nature of the problem is obvious, but I read the title wrong, that require more than three collections, then you can not think of life and death

Error List

  1. k <= log(n) / log(fac[i]) Changed k <= log(n) / log(fac[i]) + eps

  2. Fast missing power if (y & 1)

answer

1228B - Filling the Grid

Note that when filling vertical consideration, because it is covered with padding, before each filling must be checked whether there is a violation of
the last count how many can be filled from time to fill

#include <cstdio>
#include <algorithm>
 
const int mod = (int)1e9 + 7;
const int maxn = 1e3 + 10;
 
int c[maxn], r[maxn], map[maxn], w, h;
int m[maxn][maxn], v[maxn][maxn];
 
void qmul(int &x) {
  x = (x % mod) * 2 % mod;
}
 
signed main() {
  int ans = 1;
  scanf("%d %d", &h, &w);
  for (int i = 1; i <= h; ++ i) scanf("%d", &r[i]);
  for (int i = 1; i <= w; ++ i) scanf("%d", &c[i]);
  for (int i = 1; i <= h; ++ i) {
    for (int j = 1; j <= r[i]; ++ j) m[i][j] = 1, v[i][j] = 1;
    m[i][r[i] + 1] = 0, v[i][r[i] + 1] = 1;
  }
  for (int i = 1; i <= w; ++ i) {
    for (int j = 1; j <= c[i]; ++ j) {
      if (!m[j][i] && v[j][i]) return printf("0"), 0;
      m[j][i] = 1, v[j][i] = 1;
    }
    if (v[c[i] + 1][i] && m[c[i] + 1][i]) return printf("0"), 0;
    m[c[i] + 1][i] = 0, v[c[i] + 1][i] = 1;
  }
  for (int i = 1; i <= h; ++ i) {
    for (int j = 1; j <= w; ++ j) {
      if (!v[i][j]) qmul(ans);
    }
  }
  printf("%d", ans);
}

1228C - Primes and Multiplication

Direct statistical contribution of each base number of the answer, thinking that the details on the scope of

Complexity \ (O (x ^ {0.35 } + loglogx⋅log {n}) \)


#include <cmath>
#include <cstdio>
#include <algorithm>

const int maxn = 1e6 + 10;
const int modn = 1e9 + 7;

#define int long long
#define eps 1e-5

int p[maxn], n, m, t, c, fac[maxn], ans = 1;

inline void sieve() {
  for (int i = 2; i < maxn; ++ i) {
    if (!p[i]) p[++t] = i;
    for (int j = 1; j <= t && p[j] * i < maxn; ++ j) {
      p[p[j] * i] = 1; if (i % p[j] == 0) break;
    }
  }
}

inline int qpow(int x, int y, int mod) {
  int res = 1 % mod; x %= mod;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) res = res * x % mod;
  return res;
}

signed main() {
  scanf("%lld %lld", &m, &n); sieve(); 
  for (int i = 1; i <= t; ++ i) {
    if (m % p[i] == 0) fac[++c] = p[i];
    while (m % p[i] == 0) m /= p[i];
  }
  if (m != 1) fac[++c] = m;
  for (int i = 1; i <= c; ++ i) {
    int num = 0;
    for (int k = 1; k <= log(n) / log(fac[i]) + eps; ++ k)
      num += (int)(n / pow(fac[i], k));
    ans = ans * qpow(fac[i], num, modn) % modn;
  }
  printf("%lld", ans);
}

1228D - Complete Tripartite

If \ (x, y \) bordered directly connected, is referred to \ ([x, y] = 1 \) contrary to \ (0 \)

FIG easy to know this are: If \ ([X, Y] =. 1 \) , then in some different set; otherwise, it must set at different

Therefore, we can not directly connected to the first point assigned to the same group, we only need to verify the following distribution can meet \ (\ forall x \ in v_i , y \ in v_j [x, y] = 1 \)

Obviously we can not search for each point to determine whether to meet the complexity will reach \ (O (n ^ 2) \)

Difficult to find, in this case \ (m = | v1 | ⋅ | v2 | + | v2 | ⋅ | v3 | + | v3 | ⋅ | v1 | \)

Guess you like

Origin www.cnblogs.com/alessandrochen/p/11614482.html