답안 #681961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681961 2023-01-14T23:56:58 Z Mher777 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 464 KB
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
#include "grader.h"
using namespace std;

const int N = 600;

vector<int> g[N];
vector<int> a;
vector<bool> used(N);

void dfs(int u) {
	used[u] = 1;
	for (int i = 0; i < g[u].size(); i++) {
		if (!used[g[u][i]]) {
			used[g[u][i]] = true;
			a.push_back(g[u][i]);
			dfs(g[u][i]);
		}
	}
}

int findEgg (int n, vector<pair<int,int>> b) {
	for (int i = 0; i < b.size(); i++) {
		if (b[i].second < b[i].first) swap(b[i].first, b[i].second);
		g[b[i].first].push_back(b[i].second);
	}
	int l = 0, r = n - 1;
	a.push_back(1);
	dfs(1);
	while (l < r) {
		int mid = (l + r) / 2;
		vector<int> v1;
		for (int i = 0; i <= mid; i++) {
			v1.push_back(a[i]);
		}
		if (query(v1)) {
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}
	int ans = a[l];
	for (int i = 1; i <= n; i++) {
		g[i].clear();
	}
	for (int i = 1; i <= n; i++) used[i] = false;
	a.clear();
	return ans;
}

Compilation message

eastereggs.cpp: In function 'void dfs(int)':
eastereggs.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i = 0; i < g[u].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -