답안 #42451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42451 2018-02-27T10:14:39 Z ruhanhabib39 Amusement Park (JOI17_amusement_park) C++14
61 / 100
48 ms 10112 KB
#include "Joi.h"
#include <vector>
#include <algorithm>
#include <set>

using std::set;
using std::vector;
using std::fill;

namespace {
   const int MAXN = 1e4;

   int N;
   long long X;
   set<int> G[MAXN + 10];
   bool vis[MAXN + 10];

   long long ii = 0;
   void dfs(int u) {
      if(vis[u]) return;

      MessageBoard(u, bool(X & (1LL << ii)));
      vis[u] = true;
      ii = (ii + 1) % 60;
      
      for(int v : G[u]) {
         dfs(v);
      }
   }
};

void Joi(int N_, int M, int A[], int B[], long long X_, int T) {
   N = N_; X = X_;
   fill(G, G + N, set<int>());
   for(int i = 0; i < M; i++) {
      G[A[i]].insert(B[i]);
      G[B[i]].insert(A[i]);
   }
   fill(vis, vis + N, 0); ii = 0;
   dfs(0);
}
#include "Ioi.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>

using std::vector;
using std::fill;
using std::set;

namespace {
   const int MAXN = 1e4;

   int N;
   set<int> G[MAXN + 10];
   int pos[MAXN + 10];
   
   set<int> child[MAXN + 10];
   int par[MAXN + 10];

   long long res[60 + 10];

   int ii = 0;
   void dfs(int u) {
      pos[u] = ii;
      ii = (ii + 1) % 60;
      for(int v : G[u]) {
         if(pos[v] != -1) continue;
         par[v] = u;
         child[u].insert(v);
         dfs(v);
      }
   }

   void solve(int u, int p) {
      if(!std::count(res, res + 60, -1)) return;
      if(!child[u].size()) {
         res[pos[par[u]]] = Move(par[u]);
         child[par[u]].erase(u);
         solve(par[u], u);
      } else {
         auto vIt = child[u].upper_bound(p);
         if(vIt == child[u].end()) --vIt;

         int v = *vIt;
         child[u].erase(vIt);
         res[pos[v]] = Move(v);
         solve(v, u);
      }
   }

   long long work(int S, int V) {
      res[pos[S]] = V;
      solve(S, -1);
      long long X = 0;
      for(long long i = 0; i < 60; i++) {
         X |= res[i] << i;
      }
      return X;
   }
};

long long Ioi(int N_, int M, int A[], int B[], int P, int V, int T) {
   N = N_;
   for(int i = 0; i < M; i++) {
      G[A[i]].insert(B[i]);
      G[B[i]].insert(A[i]);
   }
   fill(pos, pos + N, -1);
   fill(res, res + 60, -1);
   fill(par, par + N, -1);
   fill(child, child + N, set<int>());
   par[0] = -1; dfs(0);
   return work(P, V);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2200 KB Output is correct
2 Correct 4 ms 2932 KB Output is correct
3 Correct 4 ms 3004 KB Output is correct
4 Correct 4 ms 3072 KB Output is correct
5 Correct 5 ms 3124 KB Output is correct
6 Correct 4 ms 3248 KB Output is correct
7 Correct 4 ms 3368 KB Output is correct
8 Correct 4 ms 3368 KB Output is correct
9 Correct 4 ms 3368 KB Output is correct
10 Correct 4 ms 3368 KB Output is correct
11 Correct 10 ms 3828 KB Output is correct
12 Correct 4 ms 4288 KB Output is correct
13 Correct 4 ms 4288 KB Output is correct
14 Correct 4 ms 4288 KB Output is correct
15 Correct 4 ms 4288 KB Output is correct
16 Correct 5 ms 4288 KB Output is correct
17 Correct 4 ms 4288 KB Output is correct
18 Correct 4 ms 4288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 8772 KB Output is correct
2 Correct 48 ms 10052 KB Output is correct
3 Correct 43 ms 10112 KB Output is correct
4 Correct 25 ms 10112 KB Output is correct
5 Correct 28 ms 10112 KB Output is correct
6 Correct 29 ms 10112 KB Output is correct
7 Correct 28 ms 10112 KB Output is correct
8 Correct 23 ms 10112 KB Output is correct
9 Correct 27 ms 10112 KB Output is correct
10 Correct 25 ms 10112 KB Output is correct
11 Correct 24 ms 10112 KB Output is correct
12 Correct 20 ms 10112 KB Output is correct
13 Correct 20 ms 10112 KB Output is correct
14 Correct 26 ms 10112 KB Output is correct
15 Correct 35 ms 10112 KB Output is correct
16 Correct 23 ms 10112 KB Output is correct
17 Correct 25 ms 10112 KB Output is correct
18 Correct 26 ms 10112 KB Output is correct
19 Correct 30 ms 10112 KB Output is correct
20 Correct 18 ms 10112 KB Output is correct
21 Correct 18 ms 10112 KB Output is correct
22 Correct 24 ms 10112 KB Output is correct
23 Correct 23 ms 10112 KB Output is correct
24 Correct 23 ms 10112 KB Output is correct
25 Correct 28 ms 10112 KB Output is correct
26 Correct 22 ms 10112 KB Output is correct
27 Correct 24 ms 10112 KB Output is correct
28 Correct 23 ms 10112 KB Output is correct
29 Correct 24 ms 10112 KB Output is correct
30 Correct 25 ms 10112 KB Output is correct
31 Correct 4 ms 10112 KB Output is correct
32 Correct 4 ms 10112 KB Output is correct
33 Correct 4 ms 10112 KB Output is correct
34 Correct 4 ms 10112 KB Output is correct
35 Correct 4 ms 10112 KB Output is correct
36 Correct 4 ms 10112 KB Output is correct
37 Correct 4 ms 10112 KB Output is correct
38 Correct 4 ms 10112 KB Output is correct
39 Correct 4 ms 10112 KB Output is correct
40 Correct 5 ms 10112 KB Output is correct
41 Correct 4 ms 10112 KB Output is correct
42 Correct 4 ms 10112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10112 KB Output is correct
2 Correct 4 ms 10112 KB Output is correct
3 Correct 4 ms 10112 KB Output is correct
4 Correct 6 ms 10112 KB Output is correct
5 Correct 6 ms 10112 KB Output is correct
6 Correct 6 ms 10112 KB Output is correct
7 Correct 6 ms 10112 KB Output is correct
8 Correct 6 ms 10112 KB Output is correct
9 Correct 17 ms 10112 KB Output is correct
10 Correct 17 ms 10112 KB Output is correct
11 Correct 17 ms 10112 KB Output is correct
12 Correct 4 ms 10112 KB Output is correct
13 Correct 4 ms 10112 KB Output is correct
14 Correct 4 ms 10112 KB Output is correct
15 Correct 4 ms 10112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 40 ms 10112 KB Partially correct
2 Correct 40 ms 10112 KB Output is correct
3 Partially correct 40 ms 10112 KB Partially correct
4 Partially correct 25 ms 10112 KB Partially correct
5 Correct 23 ms 10112 KB Output is correct
6 Correct 23 ms 10112 KB Output is correct
7 Partially correct 22 ms 10112 KB Partially correct
8 Partially correct 22 ms 10112 KB Partially correct
9 Partially correct 22 ms 10112 KB Partially correct
10 Correct 24 ms 10112 KB Output is correct
11 Correct 27 ms 10112 KB Output is correct
12 Partially correct 23 ms 10112 KB Partially correct
13 Correct 20 ms 10112 KB Output is correct
14 Correct 20 ms 10112 KB Output is correct
15 Correct 26 ms 10112 KB Output is correct
16 Partially correct 22 ms 10112 KB Partially correct
17 Correct 23 ms 10112 KB Output is correct
18 Correct 24 ms 10112 KB Output is correct
19 Correct 26 ms 10112 KB Output is correct
20 Correct 19 ms 10112 KB Output is correct
21 Correct 17 ms 10112 KB Output is correct
22 Partially correct 24 ms 10112 KB Partially correct
23 Partially correct 23 ms 10112 KB Partially correct
24 Partially correct 20 ms 10112 KB Partially correct
25 Partially correct 22 ms 10112 KB Partially correct
26 Partially correct 23 ms 10112 KB Partially correct
27 Partially correct 23 ms 10112 KB Partially correct
28 Partially correct 22 ms 10112 KB Partially correct
29 Partially correct 20 ms 10112 KB Partially correct
30 Partially correct 20 ms 10112 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 10112 KB Output is correct
2 Incorrect 40 ms 10112 KB Output isn't correct
3 Halted 0 ms 0 KB -