답안 #574780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574780 2022-06-09T11:51:55 Z AbdullahMW 사육제 (CEOI14_carnival) C++14
20 / 100
104 ms 328 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
 
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define db double
#define pb push_back
#define pf push_front
#define newl "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;
 
#pragma GCC diagnostic ignored "-Wunused-result"
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(15);
    if (name.size()) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

ll p[205], sz[205];
ll F(ll x)
{
    if (x == p[x]) return x;
    else return p[x] = F(p[x]);
}

void U(ll x, ll y)
{
    x = F(x);
    y = F(y);
    
    if (x != y)
    {
        if (sz[x] < sz[y]) swap(x, y);
        
        sz[x] += sz[y];
        p[y] = x; 
    }
}
int main()
{
    //fast
    //setIO("");
    
    ll n; cin >> n;
    
    for (ll i = 1; i <= n; i++)
    {
        sz[i] = 1;
        p[i] = i;
    }
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = i + 1; j <= n; j++)
        {
            cout << 2 << ' ' << i << ' ' << j << endl;
            ll suit; cin >> suit;
            if (suit == 1) U(i, j);
        }
    }
    
    unordered_map <ll, ll> occ;
    vector <ll> vec;
    vector <bool> tkn(205);
    for (ll i = 1; i <= n; i++) 
    {
        if (!tkn[F(i)])
        {
            vec.pb(F(i));
            tkn[F(i)] = true;
        }
    }
    
    sort(all(vec));
    occ[vec[0]] = 1;
    for (ll i = 1; i < vec.size(); i++)
    {
        occ[vec[i]] = i + 1;
    }
    
    cout << 0 << ' ';
    for (ll i = 1; i <= n; i++)
    {
        cout << occ[F(i)] << ' ';
    }
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:166:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  166 |     for (ll i = 1; i < vec.size(); i++)
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 81 ms 208 KB Partially correct
2 Partially correct 80 ms 280 KB Partially correct
3 Partially correct 94 ms 284 KB Partially correct
4 Partially correct 78 ms 208 KB Partially correct
5 Partially correct 72 ms 208 KB Partially correct
6 Partially correct 40 ms 208 KB Partially correct
7 Partially correct 77 ms 284 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 88 ms 208 KB Partially correct
2 Partially correct 89 ms 208 KB Partially correct
3 Partially correct 43 ms 208 KB Partially correct
4 Partially correct 96 ms 288 KB Partially correct
5 Partially correct 77 ms 208 KB Partially correct
6 Partially correct 103 ms 208 KB Partially correct
7 Partially correct 85 ms 208 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 61 ms 208 KB Partially correct
2 Partially correct 89 ms 208 KB Partially correct
3 Partially correct 78 ms 284 KB Partially correct
4 Partially correct 97 ms 284 KB Partially correct
5 Partially correct 83 ms 208 KB Partially correct
6 Partially correct 79 ms 300 KB Partially correct
7 Partially correct 81 ms 328 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 75 ms 208 KB Partially correct
2 Partially correct 97 ms 208 KB Partially correct
3 Partially correct 42 ms 208 KB Partially correct
4 Partially correct 82 ms 284 KB Partially correct
5 Partially correct 58 ms 208 KB Partially correct
6 Partially correct 78 ms 280 KB Partially correct
7 Partially correct 85 ms 328 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 91 ms 208 KB Partially correct
2 Partially correct 104 ms 208 KB Partially correct
3 Partially correct 84 ms 288 KB Partially correct
4 Partially correct 81 ms 280 KB Partially correct
5 Partially correct 68 ms 284 KB Partially correct
6 Partially correct 78 ms 288 KB Partially correct
7 Partially correct 96 ms 208 KB Partially correct