QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#462998#7303. City Unitedhos_lyricRE 72ms41628kbC++142.7kb2024-07-04 11:02:362024-07-04 11:02:37

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 11:02:37]
  • 评测
  • 测评结果:RE
  • 用时:72ms
  • 内存:41628kb
  • [2024-07-04 11:02:36]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


/*
  fix max u to select
  G[S]: induced subgraph, {u} \subseteq S \subseteq [0, u]
  
  \sum[S] [G[S]: connected]
  == \sum[S] # (color each component of G[S] in 1,2, color u in 1)  (mod 2)
  =  # (color in 0,1,2, color u in 1, no 1-2 edge)
*/

constexpr int W = 13;
constexpr int MAX = 1594323;

Int THR[W + 1];
Int MASK[MAX][3];

int N, M;
vector<int> A, B;

int main() {
  THR[0] = 1;
  for (int e = 1; e <= W; ++e) THR[e] = THR[e - 1] * 3;
  for (int p = 0; p < THR[W]; ++p) {
    for (int e = 0; e < W; ++e) {
      MASK[p][p / THR[e] % 3] |= 1<<e;
    }
  }
  
  for (; ~scanf("%d%d", &N, &M); ) {
    A.resize(M);
    B.resize(M);
    for (int i = 0; i < M; ++i) {
      scanf("%d%d", &A[i], &B[i]);
      --A[i];
      --B[i];
      if (A[i] > B[i]) swap(A[i], B[i]);
    }
    
    int ans = 0;
    bitset<MAX> crt;
    crt.set(0);
    for (int u = 0; u < N; ++u) {
      int adj = 0;
      for (int i = 0; i < M; ++i) if (B[i] == u) adj |= 1 << (u - 1 - A[i]);
      int here = 0;
      bitset<MAX> nxt;
      for (int p = 0, pp = 0; p < THR[W]; ++p, ++pp) if (crt[p]) {
        if (pp == MAX/3) pp = 0;
        nxt.flip(pp * 3 + 0);
        if (!(MASK[p][2] & adj)) { nxt.flip(pp * 3 + 1); here ^= 1; }
        if (!(MASK[p][1] & adj)) { nxt.flip(pp * 3 + 2); }
      }
cerr<<u<<": "<<here<<endl;
      ans ^= here;
      crt = nxt;
    }
    printf("%d\n", ans);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 63ms
memory: 41604kb

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 72ms
memory: 41628kb

input:

3 3
1 2
2 3
3 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Runtime Error

input:

15 31
9 5
14 5
2 7
5 15
11 14
11 9
2 6
3 4
12 1
6 8
3 5
11 10
15 6
4 1
1 2
8 9
6 12
14 10
13 2
4 5
3 8
3 15
11 6
7 5
4 6
11 2
13 15
3 2
8 4
6 13
7 10

output:


result: