답안 #42450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42450 2018-02-27T10:00:20 Z ruhanhabib39 Amusement Park (JOI17_amusement_park) C++14
79 / 100
48 ms 18440 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);
      }
   }

   long long solve(int u) {
      for(int cc = 0; std::count(res, res + 60, -1) && (child[u].size() || par[u] != -1); cc++) {
         //std::cerr << "par[" << u << "] = " << par[u] << "\n";
         //std::cerr << "child[" << u << "] = [";
         //for(int v : child[u]) std::cerr << " " << v;
         //std::cerr << "]\n";
         if(!child[u].size()) {
            res[pos[par[u]]] = Move(par[u]);
            child[par[u]].erase(u);
            u = par[u];
         } else {
            int v = *child[u].begin(); child[u].erase(child[u].begin());
            res[pos[v]] = Move(v);
            u = v;
            
         }
      }
      long long X = 0;
      for(long long i = 0; i < 60; i++) {
         X |= res[i] << i;
         //std::cerr << res[i] << " ";
      }
      //std::cerr << "\n";
      //std::cerr << "X = " << X << "\n";
      return X;
   }

   long long work(int S, int V) {
      res[pos[S]] = V;
      return solve(S);
   }
};

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 2012 KB Output is correct
2 Correct 4 ms 2756 KB Output is correct
3 Correct 4 ms 3092 KB Output is correct
4 Correct 4 ms 3176 KB Output is correct
5 Correct 4 ms 3176 KB Output is correct
6 Correct 4 ms 3300 KB Output is correct
7 Correct 4 ms 3448 KB Output is correct
8 Correct 4 ms 3472 KB Output is correct
9 Correct 5 ms 3472 KB Output is correct
10 Correct 4 ms 3472 KB Output is correct
11 Correct 13 ms 4044 KB Output is correct
12 Correct 4 ms 4616 KB Output is correct
13 Correct 4 ms 4616 KB Output is correct
14 Correct 5 ms 4616 KB Output is correct
15 Correct 4 ms 4616 KB Output is correct
16 Correct 4 ms 4616 KB Output is correct
17 Correct 4 ms 4616 KB Output is correct
18 Correct 4 ms 4616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 9108 KB Output is correct
2 Correct 40 ms 10328 KB Output is correct
3 Correct 42 ms 10328 KB Output is correct
4 Correct 23 ms 10328 KB Output is correct
5 Correct 23 ms 10328 KB Output is correct
6 Correct 23 ms 10328 KB Output is correct
7 Correct 24 ms 10328 KB Output is correct
8 Correct 23 ms 10328 KB Output is correct
9 Correct 26 ms 10328 KB Output is correct
10 Correct 25 ms 10328 KB Output is correct
11 Correct 25 ms 10328 KB Output is correct
12 Correct 20 ms 10328 KB Output is correct
13 Correct 24 ms 10328 KB Output is correct
14 Correct 20 ms 10328 KB Output is correct
15 Correct 23 ms 10328 KB Output is correct
16 Correct 23 ms 10328 KB Output is correct
17 Correct 23 ms 10328 KB Output is correct
18 Correct 23 ms 10328 KB Output is correct
19 Correct 23 ms 10328 KB Output is correct
20 Correct 18 ms 10652 KB Output is correct
21 Correct 18 ms 11084 KB Output is correct
22 Correct 24 ms 11244 KB Output is correct
23 Correct 23 ms 11472 KB Output is correct
24 Correct 23 ms 11648 KB Output is correct
25 Correct 27 ms 11856 KB Output is correct
26 Correct 36 ms 12108 KB Output is correct
27 Correct 23 ms 12248 KB Output is correct
28 Correct 23 ms 12448 KB Output is correct
29 Correct 34 ms 12552 KB Output is correct
30 Correct 29 ms 12708 KB Output is correct
31 Correct 4 ms 12864 KB Output is correct
32 Correct 5 ms 12864 KB Output is correct
33 Correct 4 ms 12864 KB Output is correct
34 Correct 4 ms 12864 KB Output is correct
35 Correct 5 ms 12864 KB Output is correct
36 Correct 4 ms 12864 KB Output is correct
37 Correct 4 ms 12864 KB Output is correct
38 Correct 5 ms 12864 KB Output is correct
39 Correct 4 ms 12864 KB Output is correct
40 Correct 5 ms 12864 KB Output is correct
41 Correct 5 ms 12864 KB Output is correct
42 Correct 4 ms 12864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 12864 KB Output is correct
2 Correct 4 ms 12864 KB Output is correct
3 Correct 4 ms 12864 KB Output is correct
4 Correct 6 ms 12864 KB Output is correct
5 Correct 6 ms 12864 KB Output is correct
6 Correct 6 ms 12864 KB Output is correct
7 Correct 6 ms 12864 KB Output is correct
8 Correct 6 ms 12864 KB Output is correct
9 Correct 25 ms 13316 KB Output is correct
10 Correct 24 ms 13872 KB Output is correct
11 Correct 20 ms 13976 KB Output is correct
12 Correct 4 ms 13976 KB Output is correct
13 Correct 4 ms 13976 KB Output is correct
14 Correct 4 ms 13976 KB Output is correct
15 Correct 4 ms 13976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 14872 KB Output is correct
2 Correct 44 ms 15768 KB Output is correct
3 Correct 41 ms 15768 KB Output is correct
4 Correct 22 ms 15768 KB Output is correct
5 Correct 32 ms 15768 KB Output is correct
6 Correct 24 ms 15768 KB Output is correct
7 Correct 32 ms 15768 KB Output is correct
8 Correct 28 ms 15768 KB Output is correct
9 Correct 24 ms 15768 KB Output is correct
10 Correct 24 ms 15768 KB Output is correct
11 Correct 23 ms 15768 KB Output is correct
12 Correct 19 ms 15768 KB Output is correct
13 Correct 20 ms 15768 KB Output is correct
14 Correct 20 ms 15768 KB Output is correct
15 Partially correct 25 ms 15768 KB Partially correct
16 Correct 25 ms 15768 KB Output is correct
17 Correct 24 ms 15768 KB Output is correct
18 Correct 25 ms 15768 KB Output is correct
19 Partially correct 23 ms 15768 KB Partially correct
20 Correct 19 ms 15768 KB Output is correct
21 Correct 18 ms 15768 KB Output is correct
22 Correct 23 ms 15768 KB Output is correct
23 Correct 25 ms 15768 KB Output is correct
24 Correct 34 ms 15768 KB Output is correct
25 Correct 32 ms 15768 KB Output is correct
26 Correct 22 ms 15768 KB Output is correct
27 Correct 23 ms 15768 KB Output is correct
28 Correct 22 ms 15768 KB Output is correct
29 Correct 22 ms 15768 KB Output is correct
30 Correct 24 ms 15768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 17212 KB Output is correct
2 Correct 41 ms 18436 KB Output is correct
3 Correct 44 ms 18440 KB Output is correct
4 Incorrect 27 ms 18440 KB Output isn't correct
5 Halted 0 ms 0 KB -