답안 #918531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918531 2024-01-30T05:58:25 Z hasanovr Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
12 ms 1676 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define vpl vector<pair<ll,ll>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define in insert
#define mp make_pair
#define vll vector<ll>
#define vint vector<int>
#define vs vector<string>
#define vbl vector<bool>
#define sll set<ll>
#define ss set<string>
#define mll map<ll, ll>
#define msl multiset<ll>
#define pque priority_queue
#define all(v) v.begin(),v.end()
#define rall(v) (v).rbegin(),(v).rend()
#define np next_permutation
#define sz(q) sizeof(q)/sizeof(q[0])
#define INF 0x3F3F3F3F
#define MAX 1e10
#define LOG 17
#define lb lower_bound
#define ub upper_bound
#define mem(q, p) memset(q, p, sizeof(q))
#define maxel *max_element
#define minel *min_element
#define yes cout << "YES\n"
#define no cout << "NO\n"
const int MOD = 1e9 + 7;
const int maxn = 5e5 + 5;
const int logn = 19;
const int sz = 2e5+5;
const int width = 3;

///gcd & lcm
ll gcd(ll q, ll p){ return p == 0 ? q : gcd(p, q%p); }
ll lcm(ll q, ll p){ return q*p / gcd(q, p); }

using namespace std;
vll g[550], eggs;
ll used[550];

void dfs(ll v){
    eggs.pb(v);
    used[v]=1;
    for (auto u:g[v]){
        if (used[u] == 0){
            dfs(u);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for (ll i = 0; i<bridges.size(); i++){
        g[bridges[i].F].pb(bridges[i].S);
        g[bridges[i].S].pb(bridges[i].F);
    }

    dfs(1);
    ll l = 0, r = N - 1;
    while (l < r){
        ll mid = (l + r)/2; vint f;
        for (ll i = 0; i<mid+1; i++) f.pb(eggs[i]);
        (query(f)) ? r = mid : l = mid+1;
    }
    return eggs[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:65:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (ll i = 0; i<bridges.size(); i++){
      |                    ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Number of queries: 4
2 Correct 1 ms 604 KB Number of queries: 4
3 Correct 1 ms 456 KB Number of queries: 4
4 Correct 1 ms 456 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 732 KB Number of queries: 8
2 Correct 8 ms 1004 KB Number of queries: 9
3 Correct 12 ms 1664 KB Number of queries: 9
4 Correct 10 ms 1008 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1676 KB Number of queries: 9
2 Correct 11 ms 1248 KB Number of queries: 9
3 Correct 11 ms 1264 KB Number of queries: 9
4 Correct 11 ms 1368 KB Number of queries: 9