답안 #41804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41804 2018-02-21T09:06:33 Z RockyB Amusement Park (JOI17_amusement_park) C++14
0 / 100
52 ms 22752 KB
/// In The Name Of God

#include <bits/stdc++.h>
#include "Joi.h"

#define ioi exit(0);

using namespace std;

class Solve1 {
	static const int N = 2e5 + 7;

	int n, m, T;
	long long x;
	int *a, *b;


	int cnt;
	vector <int> g[N];
	bool was[N];

	public:
		Solve1() {}
		Solve1(int n, int m, int a[], int b[], long long x, int T) :
		n(n), m(m), a(a), b(b), x(x), T(T) {}

		void dfs(int v = 0) {
			was[v] = 1;
			if (cnt <= 59) {
				int type = (x & (1LL << cnt)) > 0;
				MessageBoard(v, type);
			}
			else {
				MessageBoard(v, 0);
			}
			++cnt;
			for (auto to : g[v]) {
				if (!was[to]) {
					dfs(to);
				}
			}
		}
		void solve() {
			for (int i = 0; i < m; i++) {
				g[a[i]].push_back(b[i]);
				g[b[i]].push_back(a[i]);
			}
			dfs();
		}
} S1;


void Joi(int n, int m, int a[], int b[], long long x, int T) {
	S1 = Solve1(n, m, a, b, x, T);
	S1.solve();
}




/*int32_t main() {

}
*/
/*int32_t main() {
	S1.solve();
	ioi
}*/


/*int32_t main() {

	return 0;
}*/

/*#ifdef IOI2018
int main() {
	freopen ("in.txt", "r", stdin);
	
	ioi
}
#endif
*/
/// In The Name Of God

#include <bits/stdc++.h>
#include "Ioi.h"

#define ioi exit(0);

using namespace std;

class Solve2 {
	static const int N = 2e5 + 7;

	int n, m, p, v, T;
	int *a, *b;

	vector <int> g[N];
	bool was[N];

	long long res;

	public: 
		Solve2() {}
		Solve2(int n, int m, int a[], int b[], int p, int v, int T) :
		n(n), m(m), a(a), b(b), p(p), v(v), T(T) {}

		void dfs(int v) {
			was[v] = 1;
			if (was[0]) return;
			for (auto to : g[v]) {
				if (!was[to] && !was[0]) {
					last = Move(to);
					dfs(to);
					if (!was[0]) {
						last = Move(v);
					}
				}
			}
		}
		int cnt;
		int last;
		void dfs1(int v = 0) {	
			was[v] = 1;
			if (cnt <= 59) {
				res += (1LL << cnt) * last;
			}	
			cnt++;
			if (cnt >= 60) return;
			for (auto to : g[v]) {
				if (was[to]) continue;
				last = Move(to);
				dfs1(to);
				Move(v);
			}
		}
		long long solve() {
			for (int i = 0; i < m; i++) {
				g[a[i]].push_back(b[i]);
				g[b[i]].push_back(a[i]);
			}
			last = v;
			dfs(p);
			memset(was, 0, sizeof(was));
			cnt = 0;
			dfs1();
			return res;
		}

} S2;

long long Ioi(int n, int m, int a[], int b[], int p, int v, int t) {
	S2 = Solve2(n, m, a, b, p, v, t);
	return S2.solve();
}	

#ifdef IOI2018
int main() {
	freopen ("in.txt", "r", stdin);
	S2.solve();
	ioi
}
#endif

Compilation message

Joi.cpp: In constructor 'Solve1::Solve1(int, int, int*, int*, long long int, int)':
Joi.cpp:15:11: warning: 'Solve1::b' will be initialized after [-Wreorder]
  int *a, *b;
           ^
Joi.cpp:14:12: warning:   'long long int Solve1::x' [-Wreorder]
  long long x;
            ^
Joi.cpp:24:3: warning:   when initialized here [-Wreorder]
   Solve1(int n, int m, int a[], int b[], long long x, int T) :
   ^
Joi.cpp:14:12: warning: 'Solve1::x' will be initialized after [-Wreorder]
  long long x;
            ^
Joi.cpp:13:12: warning:   'int Solve1::T' [-Wreorder]
  int n, m, T;
            ^
Joi.cpp:24:3: warning:   when initialized here [-Wreorder]
   Solve1(int n, int m, int a[], int b[], long long x, int T) :
   ^

Ioi.cpp: In constructor 'Solve2::Solve2(int, int, int*, int*, int, int, int)':
Ioi.cpp:14:11: warning: 'Solve2::b' will be initialized after [-Wreorder]
  int *a, *b;
           ^
Ioi.cpp:13:12: warning:   'int Solve2::p' [-Wreorder]
  int n, m, p, v, T;
            ^
Ioi.cpp:23:3: warning:   when initialized here [-Wreorder]
   Solve2(int n, int m, int a[], int b[], int p, int v, int T) :
   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 19804 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 22460 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 22600 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 22752 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 22752 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -