답안 #42452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42452 2018-02-27T10:18:59 Z ruhanhabib39 Amusement Park (JOI17_amusement_park) C++14
77 / 100
53 ms 10224 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, -1);
      }
   }

   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 2140 KB Output is correct
2 Correct 4 ms 2812 KB Output is correct
3 Correct 5 ms 2864 KB Output is correct
4 Correct 4 ms 2960 KB Output is correct
5 Correct 4 ms 3056 KB Output is correct
6 Correct 5 ms 3104 KB Output is correct
7 Correct 5 ms 3152 KB Output is correct
8 Correct 5 ms 3152 KB Output is correct
9 Correct 5 ms 3152 KB Output is correct
10 Correct 4 ms 3152 KB Output is correct
11 Correct 13 ms 3704 KB Output is correct
12 Correct 6 ms 4256 KB Output is correct
13 Correct 4 ms 4256 KB Output is correct
14 Correct 5 ms 4256 KB Output is correct
15 Correct 5 ms 4256 KB Output is correct
16 Correct 4 ms 4256 KB Output is correct
17 Correct 5 ms 4256 KB Output is correct
18 Correct 4 ms 4256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 8800 KB Output is correct
2 Correct 47 ms 10080 KB Output is correct
3 Correct 43 ms 10080 KB Output is correct
4 Correct 23 ms 10080 KB Output is correct
5 Correct 28 ms 10080 KB Output is correct
6 Correct 24 ms 10080 KB Output is correct
7 Correct 25 ms 10080 KB Output is correct
8 Correct 31 ms 10080 KB Output is correct
9 Correct 25 ms 10080 KB Output is correct
10 Correct 25 ms 10080 KB Output is correct
11 Correct 25 ms 10080 KB Output is correct
12 Correct 28 ms 10080 KB Output is correct
13 Correct 22 ms 10080 KB Output is correct
14 Correct 23 ms 10080 KB Output is correct
15 Correct 30 ms 10080 KB Output is correct
16 Correct 33 ms 10080 KB Output is correct
17 Correct 31 ms 10080 KB Output is correct
18 Correct 26 ms 10080 KB Output is correct
19 Correct 25 ms 10080 KB Output is correct
20 Correct 20 ms 10080 KB Output is correct
21 Correct 17 ms 10080 KB Output is correct
22 Correct 23 ms 10080 KB Output is correct
23 Correct 24 ms 10080 KB Output is correct
24 Correct 25 ms 10080 KB Output is correct
25 Correct 28 ms 10080 KB Output is correct
26 Correct 25 ms 10080 KB Output is correct
27 Correct 22 ms 10080 KB Output is correct
28 Correct 24 ms 10080 KB Output is correct
29 Correct 24 ms 10080 KB Output is correct
30 Correct 25 ms 10080 KB Output is correct
31 Correct 4 ms 10080 KB Output is correct
32 Correct 4 ms 10080 KB Output is correct
33 Correct 4 ms 10080 KB Output is correct
34 Correct 4 ms 10080 KB Output is correct
35 Correct 4 ms 10080 KB Output is correct
36 Correct 4 ms 10080 KB Output is correct
37 Correct 5 ms 10080 KB Output is correct
38 Correct 4 ms 10080 KB Output is correct
39 Correct 5 ms 10080 KB Output is correct
40 Correct 4 ms 10080 KB Output is correct
41 Correct 5 ms 10080 KB Output is correct
42 Correct 4 ms 10080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10080 KB Output is correct
2 Correct 4 ms 10080 KB Output is correct
3 Correct 4 ms 10080 KB Output is correct
4 Correct 7 ms 10080 KB Output is correct
5 Correct 6 ms 10080 KB Output is correct
6 Correct 6 ms 10080 KB Output is correct
7 Correct 7 ms 10080 KB Output is correct
8 Correct 6 ms 10080 KB Output is correct
9 Correct 19 ms 10080 KB Output is correct
10 Correct 18 ms 10080 KB Output is correct
11 Correct 17 ms 10080 KB Output is correct
12 Correct 4 ms 10080 KB Output is correct
13 Correct 4 ms 10080 KB Output is correct
14 Correct 4 ms 10080 KB Output is correct
15 Correct 4 ms 10080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 10080 KB Output is correct
2 Correct 53 ms 10080 KB Output is correct
3 Correct 43 ms 10080 KB Output is correct
4 Correct 30 ms 10080 KB Output is correct
5 Correct 24 ms 10080 KB Output is correct
6 Correct 23 ms 10080 KB Output is correct
7 Correct 24 ms 10080 KB Output is correct
8 Correct 23 ms 10080 KB Output is correct
9 Correct 24 ms 10080 KB Output is correct
10 Correct 27 ms 10080 KB Output is correct
11 Correct 27 ms 10080 KB Output is correct
12 Correct 20 ms 10080 KB Output is correct
13 Correct 19 ms 10080 KB Output is correct
14 Correct 24 ms 10080 KB Output is correct
15 Correct 27 ms 10080 KB Output is correct
16 Correct 25 ms 10080 KB Output is correct
17 Correct 25 ms 10080 KB Output is correct
18 Correct 23 ms 10080 KB Output is correct
19 Partially correct 35 ms 10080 KB Partially correct
20 Correct 19 ms 10080 KB Output is correct
21 Correct 17 ms 10080 KB Output is correct
22 Correct 26 ms 10080 KB Output is correct
23 Correct 36 ms 10080 KB Output is correct
24 Correct 26 ms 10080 KB Output is correct
25 Correct 28 ms 10080 KB Output is correct
26 Correct 25 ms 10080 KB Output is correct
27 Correct 23 ms 10080 KB Output is correct
28 Correct 23 ms 10080 KB Output is correct
29 Correct 22 ms 10080 KB Output is correct
30 Correct 23 ms 10080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 10080 KB Output is correct
2 Correct 52 ms 10080 KB Output is correct
3 Correct 45 ms 10152 KB Output is correct
4 Incorrect 23 ms 10224 KB Output isn't correct
5 Halted 0 ms 0 KB -