Submission #69468000


Source Code Expand

// clang-format off

#ifdef LOCAL
#include"/home/aoriika/kyopro/atcoder/all.h"
#else
#include<bits/stdc++.h>
#ifdef ATCODER
#include<atcoder/all>
#endif  // ATCODER
#endif  // LOCAL

/* accelration */
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
// struct Fast {Fast() {cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);}} fast;

/* alias */
// type
using ull = unsigned long long;
using ll = long long;
using ld = long double;
// pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
// vector
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vs = std::vector<std::string>;
using vpii = std::vector<pii>;
using vpll = std::vector<pll>;
template<class T> using vv = std::vector<std::vector<T>>;
// unordered set
using usi = std::unordered_set<int>;
using usll = std::unordered_set<ll>;
using uss = std::unordered_set<std::string>;
template<class T, class U> using um = std::unordered_map<T, U>;

/* define short */
#define pb push_back
#define mp make_pair
#define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__)
#define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__)

/* REP macro */
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP1(i, n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

/* debug */
#ifdef LOCAL
#define debug(x) std::cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << std::endl;
#else
#define debug(x)
#endif

/* func */
inline int in_int() {
    int ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (std::isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; std::isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    std::ungetc(ch, stdin);
    return sgn * ret;
}
inline ll in_ll() {    
    ll ret = 0;
    int ch = getchar_unlocked(), sgn = 1;
    while (std::isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; std::isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    std::ungetc(ch, stdin);
    return sgn * ret;
}
inline std::string in_str(size_t buf = 0) {
    std::string x;
    int ch = getchar_unlocked();
    if(buf)
        x.reserve(buf);
    while (std::isspace(ch)) { ch = getchar_unlocked(); }
    for(; !std::isspace(ch); ch = getchar_unlocked())
        x.push_back((char)ch);
    return x;
}
inline double in_double() {
    double ret;
    char buf[32];
    char *ptr;
    buf[0] = (char)getchar_unlocked();
    while(isspace((int)buf[0])) {buf[0] = (char)getchar_unlocked();}
    for(ptr=&buf[0];!std::isspace((int)*ptr)&&ptr-&buf[0]<31;*ptr=(char)getchar_unlocked()) ptr++;
    auto result = std::from_chars(&buf[0], ptr, ret);
    assert(result.ec==std::errc{});
    return ret;
}
constexpr inline int ctoi(const char c) {return c - '0';}
vi Eratosthenes(const int N){
    std::vector<bool> is_prime(N + 1, true); vi P;
    rep(i,2,N+1){
        if( is_prime[i] ){
            for( int j = 2 * i; j <= N; j += i ){ is_prime[j] = false; } P.emplace_back(i);
        }
    } return P;
}
vpll prime_factorize(const ll N) {
    vpll res;
    ll n = N;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; while (N % a == 0) { ++ex; n/=a; }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N,1});
    return res;
}
std::vector<std::pair<char, int>> RLE(const std::string &S)
{
    std::vector<std::pair<char, int>> res;
    int l = 0;
    rep(i, 1, std::ssize(S))
    {
        if(S[i-1] != S[i])
        {
            res.emplace_back(S[i-1], i-l);
            l = i;
        }
    }
    res.emplace_back(S.back(), S.length()-l);
    return res;
}
inline void print(const char *ptr, const std::string &end = "\n") {
    for(int i=0;ptr[i]!='\0';i++) putchar_unlocked((int)ptr[i]);
    for(auto c:end) putchar_unlocked((int)c);
}
inline void print(const std::string &x, const std::string &end = "\n") {print(x.data(), end);}
template <std::integral T> inline void print(const T x, const std::string &end = "\n")
{
    char buf[32];
    std::to_chars_result result = std::to_chars(&(buf[0]), &(buf[31]), x);
    assert(result.ec==std::errc{});
    *result.ptr = '\0';
    print(buf, end);
}
template <std::floating_point T> inline void print(const T x, const std::string &end = "\n")
{
    char buf[32];
    std::to_chars_result result = std::to_chars(&(buf[0]), &(buf[31]), x, std::chars_format::fixed, 20);
    assert(result.ec==std::errc{});
    *result.ptr = '\0';
    print(buf, end);
}
template <typename T> inline void print(const std::vector<T>& v, const std::string &s = " ")
    {for(int i=0;i<ssize(v);i++) print(v[i], (i==ssize(v)-1 ? "\n" : s));}
template <typename T> inline void print(const vv<T>& v, const std::string &s = " ")
    {for(auto e:v) print(e, s);}
template <typename T, typename S> inline void print(const std::pair<T, S>& p)
    {print(p.first, " "); print(p.second);}
template <typename T, typename S> inline void print(const std::vector<std::pair<T, S>>& v)
    {for (auto&& p : v) print(p);}
template <typename T, typename S> inline void print(const std::map<T, S>& m)
    {for (auto&& p : m) print(p);}
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

// clang-format on
using namespace std;

vi solve(int N, int M, int K, const vi &A, const vi &B)
{
    vector<usi> R(N);
    vi ans;
    rep(i, K)
    {
        R[A[i] - 1].insert(B[i]);
        if (R[A[i] - 1].size() == M)
            ans.push_back(A[i]);
    }
    return ans;
}

int main()
{
    int N = in_int(), M = in_int(), K = in_int();
    vi A(K), B(K);
    rep(i,K) {A[i]=in_int(); B[i]=in_int();}
    auto ans = solve(N, M, K, A, B);
    for (auto x : ans)
        cout << x << ' ';
    cout << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Perfect
User aoriika
Language C++ 23 (gcc 12.2)
Score 200
Code Size 6463 Byte
Status AC
Exec Time 1 ms
Memory 3620 KiB

Compile Error

Main.cpp: In function ‘vi solve(int, int, int, const vi&, const vi&)’:
Main.cpp:182:32: warning: comparison of integer expressions of different signedness: ‘std::unordered_set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  182 |         if (R[A[i] - 1].size() == M)
      |             ~~~~~~~~~~~~~~~~~~~^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 21
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3504 KiB
example_01.txt AC 1 ms 3516 KiB
hand_00.txt AC 1 ms 3552 KiB
hand_01.txt AC 1 ms 3516 KiB
hand_02.txt AC 1 ms 3484 KiB
hand_03.txt AC 1 ms 3556 KiB
hand_04.txt AC 1 ms 3500 KiB
hand_05.txt AC 1 ms 3536 KiB
hand_06.txt AC 1 ms 3536 KiB
random_00.txt AC 1 ms 3548 KiB
random_01.txt AC 1 ms 3524 KiB
random_02.txt AC 1 ms 3484 KiB
random_03.txt AC 1 ms 3484 KiB
random_04.txt AC 1 ms 3540 KiB
random_05.txt AC 1 ms 3496 KiB
random_06.txt AC 1 ms 3552 KiB
random_07.txt AC 1 ms 3528 KiB
random_08.txt AC 1 ms 3516 KiB
random_09.txt AC 1 ms 3620 KiB
random_10.txt AC 1 ms 3580 KiB
random_11.txt AC 1 ms 3520 KiB