답안 #698619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698619 2023-02-14T05:31:58 Z cig32 Newspapers (CEOI21_newspapers) C++17
0 / 100
32 ms 51412 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
int bm(int b, int p) {
  if(p==0) return 1 % MOD;
  int r = bm(b, p >> 1);
  if(p&1) return (((r*r) % MOD) * b) % MOD;
  return (r*r) % MOD;
}
int inv(int b) { 
  return bm(b, MOD-2);
}
int fastlog(int x) {
  return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1);
}
void printcase(int i) { cout << "Case #" << i << ": "; }

vector<int> adj[1029];
int state[(1 << 20)];
bool vis[(1 << 20)];
vector<int> trans[(1 << 20)];
int msk[21];
void solve(int tc) {
  int n, m; cin >> n >> m;
  for(int i=0; i<(1<<n)-1; i++) state[i] = 1e9;
  state[(1<<n)-1] = 0;
  for(int i=0; i<m; i++) {
    int u, v; cin >> u >> v;
    u--, v--;
    msk[u] |= (1 << v);
    msk[v] |= (1 << u);
  }

  for(int i=0; i<(1<<n); i++) {
    int nxt= 0;
    for(int j=0; j<n; j++) {
      if(i & (1<<j)) {
        nxt |= msk[j];
      }
    }
    for(int j=0; j<n; j++) {
      int rl = nxt | (1<<j);
      rl ^= (1<<j);
      trans[i].push_back(rl);
    }
  }
  queue<int> q;
  q.push((1<<n) - 1);
  while(q.size()) {
    int f=q.front(); q.pop();
    if(!vis[f]) {
      vis[f] = 1;
      for(int x: trans[f]) {
        if(!vis[x] && state[x]>state[f] + 1) {
          state[x] = state[f] + 1; q.push(x);
        }
      }
    }
  }
  cout << (state[0] == 1e9 ? "NO\n" : "YES\n");
  cout << "1\n";
  cout << "1\n";
  
  

}
int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 24916 KB Output is correct
2 Partially correct 13 ms 24916 KB Failed to provide a successful strategy.
3 Partially correct 14 ms 24976 KB Failed to provide a successful strategy.
4 Partially correct 14 ms 24996 KB Failed to provide a successful strategy.
5 Partially correct 15 ms 24912 KB Failed to provide a successful strategy.
6 Partially correct 13 ms 24980 KB Failed to provide a successful strategy.
7 Incorrect 13 ms 24972 KB Extra information in the output file
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 24880 KB Output is correct
2 Partially correct 12 ms 24884 KB Failed to provide a successful strategy.
3 Partially correct 13 ms 24916 KB Failed to provide a successful strategy.
4 Partially correct 13 ms 24916 KB Failed to provide a successful strategy.
5 Partially correct 12 ms 24992 KB Failed to provide a successful strategy.
6 Partially correct 13 ms 24884 KB Failed to provide a successful strategy.
7 Partially correct 13 ms 24980 KB Failed to provide a successful strategy.
8 Partially correct 13 ms 24968 KB Failed to provide a successful strategy.
9 Partially correct 13 ms 25040 KB Failed to provide a successful strategy.
10 Partially correct 14 ms 25188 KB Failed to provide a successful strategy.
11 Runtime error 32 ms 51412 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 24916 KB Output is correct
2 Partially correct 13 ms 24916 KB Failed to provide a successful strategy.
3 Partially correct 14 ms 24976 KB Failed to provide a successful strategy.
4 Partially correct 14 ms 24996 KB Failed to provide a successful strategy.
5 Partially correct 15 ms 24912 KB Failed to provide a successful strategy.
6 Partially correct 13 ms 24980 KB Failed to provide a successful strategy.
7 Incorrect 13 ms 24972 KB Extra information in the output file
8 Halted 0 ms 0 KB -