답안 #681936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681936 2023-01-14T22:32:33 Z Mher777 Easter Eggs (info1cup17_eastereggs) C++17
6 / 100
2 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;

int findEgg (int n, vector<pair<int,int>> b) {
	map<int, vector<int>> mp;
	for (int i = 0; i < b.size(); i++) {
		if (b[i].second < b[i].first) swap(b[i].first, b[i].second);
		mp[b[i].first].push_back(b[i].second);
	}
	sort(b.begin(), b.end());
	vector<bool> used(n + 5);
	for (int i = 0; i < b.size(); i++) {
		if (query({ b[i].first, b[i].second }) == 1) {
			if (query({ b[i].first }) == 1) {
				return b[i].first;
			}
			else {
				return b[i].second;
			}
		}
		else {
			used[b[i].first] = true;
			used[b[i].second] = true;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!used[i] && query({i})) {
			return i;
		}
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:28: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]
   28 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
eastereggs.cpp:34: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]
   34 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
eastereggs.cpp:27:24: warning: control reaches end of non-void function [-Wreturn-type]
   27 |  map<int, vector<int>> mp;
      |                        ^~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 208 KB Number of queries: 15
2 Partially correct 1 ms 208 KB Number of queries: 16
3 Partially correct 1 ms 208 KB Number of queries: 16
4 Partially correct 1 ms 208 KB Number of queries: 16
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -