Submission #65002680
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
#include <cassert>
#include <functional>
#include <random>
using namespace atcoder;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vvvvvll = vector<vvvvll>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vld = vector<long double>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vc = vector<char>;
using vvc = vector<vc>;
using lll = __int128_t;
using vs = vector<string>;
using pii = pair<long long, long long>;
using mint = modint1000000007;
#define mp make_pair
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++)
#define rep(i, n) for (ll i = (0); i < (ll)(n); i++)
#define rrep(i, n) for (ll i = (1); i < (ll)(n + 1); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define rrepd(i, n) for (ll i = n; i >= 1; i--)
#define ALL(n) n.begin(), n.end()
#define rALL(n) n.rbegin(), n.rend()
#define fore(i, a) for (auto &i : a)
#define IN(a, x, b) (a <= x && x < b)
#define IN(a, x, b) (a <= x && x < b)
#define INIT \
std::ios::sync_with_stdio(false); \
std::cin.tie(0);
template <class T>
void output(T &W, bool x)
{
cout << W;
if (!x)
cout << ' ';
else
cout << endl;
return;
}
// sは改行するか否かを表す
template <class T>
void output(vector<T> &W, bool s)
{
rep(i, W.size()) { output(W[i], ((i == W.size() - 1) || s)); }
return;
}
// sは改行するか否かを表す
template <class T>
void output(vector<vector<T>> &W, bool s)
{
rep(i, W.size()) { output(W[i], s); }
return;
}
template <class T>
T vectorsum(vector<T> &W, int a, int b)
{
return accumulate(W.begin() + a, W.end() + b, (T)0);
}
template <class T>
T vectorsum(vector<T> &W)
{
int b = W.size();
return accumulate(ALL(W), (T)0);
}
template <class T>
inline T CHMAX(T &a, const T b)
{
return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T &a, const T b)
{
return a = (a > b) ? b : a;
}
template <class T>
void input(T &W)
{
cin >> W;
return;
}
template <class T>
void input(vector<T> &W)
{
for (auto &u : W)
input(u);
return;
}
template <class T, class TT>
void add(T &W, TT &a)
{
W += a;
return;
}
template <class T>
void add(vector<T> &W, vector<T> &a)
{
rep(i, W.size()) add(W[i], a[i]);
}
template <class T>
void add(T &W, T &a)
{
W += a;
}
template <class T, class TT>
void add(vector<T> &W, TT a)
{
for (auto &u : W)
add(u, a);
return;
}
const long double EPS = 1e-10;
const double INF = 1e18;
#define LOOP(n) REPI($_, (n))
#define REPI(i, n) \
for (int i = 0, i##_length = static_cast<int>(n); i < i##_length; ++i)
#define REPF(i, l, r) \
for (std::common_type_t<decltype(l), decltype(r)> i = (l), i##_last = (r); \
i < i##_last; ++i)
#define REPIS(i, l, r, s) \
for (std::common_type_t<decltype(l), decltype(r), decltype(s)> \
i = (l), \
i##_last = (r); \
i < i##_last; i += (s))
#define REPR(i, n) for (auto i = (n); --i >= 0;)
#define REPB(i, l, r) \
for (std::common_type_t<decltype(l), decltype(r)> i = (r), i##_last = (l); \
--i >= i##_last;)
#define REPRS(i, l, r, s) \
for (std::common_type_t<decltype(l), decltype(r), decltype(s)> \
i = (l) + ((r) - (l) - 1) / (s) * (s), \
i##_last = (l); \
i >= i##_last; (i -= (s)))
#define REP(...) $OVERLOAD4(__VA_ARGS__, REPIS, REPF, REPI, LOOP)(__VA_ARGS__)
#define REPD(...) $OVERLOAD4(__VA_ARGS__, REPRS, REPB, REPR)(__VA_ARGS__)
#define FORO(i, n) \
for (int i = 0, i##_last = static_cast<int>(n); i <= i##_last; ++i)
#define FORI(i, l, r) \
for (std::common_type_t<decltype(l), decltype(r)> i = (l), i##_last = (r); \
i <= i##_last; ++i)
#define FORIS(i, l, r, s) \
for (std::common_type_t<decltype(l), decltype(r), decltype(s)> \
i = (l), \
i##_last = (r); \
i <= i##_last; i += (s))
#define FORRO(i, n) for (auto i = (n); i >= 0; --i)
#define FORR(i, l, r) \
for (std::common_type_t<decltype(l), decltype(r)> i = (r), i##_last = (l); \
i >= i##_last; --i)
#define FORRS(i, l, r, s) \
for (std::common_type_t<decltype(l), decltype(r), decltype(s)> \
i = (l) + ((r) - (l)) / (s) * (s), \
i##_last = (l); \
i >= i##_last; i -= (s))
#define FOR(...) $OVERLOAD4(__VA_ARGS__, FORIS, FORI, FORO)(__VA_ARGS__)
#define FORD(...) $OVERLOAD4(__VA_ARGS__, FORRS, FORR, FORRO)(__VA_ARGS__)
#define ITR1(e0, v) for (const auto &e0 : (v))
#define ITRP1(e0, v) for (auto e0 : (v))
#define ITRR1(e0, v) for (auto &e0 : (v))
#define ITR2(e0, e1, v) for (const auto [e0, e1] : (v))
#define ITRP2(e0, e1, v) for (auto [e0, e1] : (v))
#define ITRR2(e0, e1, v) for (auto &[e0, e1] : (v))
#define ITR3(e0, e1, e2, v) for (const auto [e0, e1, e2] : (v))
#define ITRP3(e0, e1, e2, v) for (auto [e0, e1, e2] : (v))
#define ITRR3(e0, e1, e2, v) for (auto &[e0, e1, e2] : (v))
#define ITR4(e0, e1, e2, e3, v) for (const auto [e0, e1, e2, e3] : (v))
#define ITRP4(e0, e1, e2, e3, v) for (auto [e0, e1, e2, e3] : (v))
#define ITRR4(e0, e1, e2, e3, v) for (auto &[e0, e1, e2, e3] : (v))
#define ITR(...) $OVERLOAD5(__VA_ARGS__, ITR4, ITR3, ITR2, ITR1)(__VA_ARGS__)
#define ITRP(...) \
$OVERLOAD5(__VA_ARGS__, ITRP4, ITRP3, ITRP2, ITRP1)(__VA_ARGS__)
#define ITRR(...) \
$OVERLOAD5(__VA_ARGS__, ITRR4, ITRR3, ITRR2, ITRR1)(__VA_ARGS__)
long long Power(long long a, long long b, long long m)
{
long long p = a, Answer = 1;
for (int i = 0; i < 63; i++)
{
ll wari = (1LL << i);
if ((b / wari) % 2 == 1)
{
Answer %= m;
Answer = (Answer * p) % m; // 「a の 2^i 乗」が掛けられるとき
}
p %= m;
p = (p * p) % m;
}
return Answer;
}
template <typename T>
// [0,M)についての階上を求める
vector<T> KAI(int M)
{
vector<T> kai(M, 1);
rep(i, M - 1) { kai[i + 1] = kai[i] * (i + 1); }
return kai;
}
template <typename T>
vector<T> DIV(int M)
{
vector<T> kai = KAI<T>(M), div(M, 1);
rep(i, M - 1) { div[i + 1] = 1 / kai[i + 1]; }
return div;
}
/* 関数名 n_ary(string str, int n, int m)
説明 n 進数で表現された数値を文字列 str で受け取り、m
進数に直して文字列で出力する。 使用ライブラリ string 使用自作関数 ntodec,
decton, pow_ll 制約事項 36進数までの対応。負の値には対応していない。
*/
string n_ary(string &str, int n, int m)
{
str = "";
while (n)
{
str.push_back('0' + n % m);
n /= m;
}
reverse(ALL(str));
return str;
}
template <typename T>
vector<T> compress(vector<T> &X)
{
// ソートした結果を vals に
vector<pair<T, int>> vals(X.size());
for (int i = 0; i < X.size(); i++)
vals[i] = {X[i], i};
sort(ALL(vals));
// 各要素ごとに二分探索で位置を求める
for (int i = 0; i < (int)X.size(); i++)
{
X[i] = lower_bound(vals.begin(), vals.end(), (pair<T, int>){X[i], i}) -
vals.begin();
}
return X;
}
long long extGCD(long long a, long long b, long long &x, long long &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
long long d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
std::ostream &operator<<(std::ostream &dest, __int128_t value)
{
std::ostream::sentry s(dest);
if (s)
{
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do
{
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0)
{
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len)
{
dest.setstate(std::ios_base::badbit);
}
}
return dest;
}
// 削除可能priorty_queue
struct eraseable_priority_queue
{
priority_queue<ll> Q1, Q2;
void push(ll K) { Q1.emplace(K); }
void erase(ll K) { Q2.emplace(K); }
ll top()
{
while (!Q1.empty() && Q2.top() != Q1.top())
Q1.pop(), Q2.pop();
return Q1.top();
}
bool empty()
{
while (!Q1.empty() && Q2.top() != Q1.top())
Q1.pop(), Q2.pop();
return Q1.empty();
}
};
struct TRI
{
ll a;
ll b;
ll c;
ll d;
};
bool operator>(const TRI &r, const TRI &l)
{
return (r.a > l.a | (r.a == l.a & r.b > l.b) |
(r.a == l.a & r.b == l.b & r.c > l.c));
}
bool operator<(const TRI &r, const TRI &l)
{
return (r.a < l.a | (r.a == l.a & r.b < l.b) |
(r.a == l.a & r.b == l.b & r.c < l.c));
}
ll half = 499122177;
#include <bits/stdc++.h>
using namespace std;
// 実装はUnion by sizeで行っている
class UnionFind
{
public:
UnionFind() = default;
/// @param n 要素数
explicit UnionFind(size_t n)
: m_parentsOrSize(n, -1), N(n), MAX(n, -1), MIN(n, n + 1)
{
for (int i = 0; i < n; i++)
{
MAX[i] = i, MIN[i] = i;
}
}
/// @brief 頂点 i の root のインデックスを返します。
/// @param i 調べる頂点のインデックス
/// @return 頂点 i の root のインデックス
int leader(int i)
{
if (m_parentsOrSize[i] < 0)
{
return i;
}
const int root = leader(m_parentsOrSize[i]);
// 経路圧縮
return (m_parentsOrSize[i] = root);
}
/// @param w (b の重み) - (a の重み)
/// a を含むグループと b を含むグループを併合する
// グループが一致している場合何もしない
void merge(int a, int b)
{
a = leader(a);
b = leader(b);
if (a != b)
{
// union by size (小さいほうが子になる)
if (-m_parentsOrSize[a] < -m_parentsOrSize[b])
{
std::swap(a, b);
}
m_parentsOrSize[a] += m_parentsOrSize[b];
m_parentsOrSize[b] = a;
MAX[leader(a)] = max(MAX[a], MAX[b]);
MIN[leader(a)] = min(MIN[a], MIN[b]);
}
}
int Maxim(int a) { return MAX[a]; }
int Minim(int a) { return MIN[a]; }
/// @brief a と b が同じグループに属すかを返します。
/// @param a 一方のインデックス
/// @param b 他方のインデックス
/// @return a と b が同じグループに属す場合 true, それ以外の場合は false
/// a と b が同じグループに属すかを返す
bool same(int a, int b) { return (leader(a) == leader(b)); }
/// @brief i が属するグループの要素数を返します。
/// @param i インデックス
/// @return i が属するグループの要素数
int size(int i) { return -m_parentsOrSize[leader(i)]; }
vector<vector<int>> Groups()
{
vector<vector<int>> G;
int sum = 0;
vector<int> number(N, -1);
for (int i = 0; i < N; i++)
{
int a = leader(i);
if (number[a] == -1)
{
number[a] = sum;
G.emplace_back(vector<int>{});
G[sum].emplace_back(i);
sum++;
}
else
{
G[number[i]].emplace_back(i);
}
}
return G;
}
private:
// m_parentsOrSize[i] は i の 親,
// ただし root の場合は (-1 * そのグループに属する要素数)
int N;
std::vector<int> m_parentsOrSize;
vll MIN;
vll MAX;
};
int target;
bool f(int v) { return v < target; }
#include <cmath>
void solve()
{
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(20);
ll a = 0, b = 0;
ll a2, b2, c2;
ll a1 = 0, b1 = 0;
ll c = 0, c1;
ll p = 0;
ll N, M;
ll t;
ll K;
ll h, w;
string S, T = "";
}
void Yes(bool b)
{
if (b)
cout << "Yes" << '\n';
else
cout << "No" << '\n';
}
ll op(ll a, ll b) { return max(a, b); }
ll e() { return -INF; }
ll mapping(ll a, ll b) { return a + b; }
ll composition(ll a, ll b) { return a + b; }
ll id() { return 0; }
struct TRK
{
ll a;
ll b;
ll c;
};
bool operator>(const TRK &r, const TRK &l) { return r.a > l.a; }
bool operator<(const TRK &r, const TRK &l) { return r.a < l.a; }
vll dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
int main()
{
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(20);
ll a = 0, b = 0;
ll a2, b2, c2;
ll a1 = 0, b1 = 0;
ll c = 0, c1;
ll p = 0;
ll N, M;
ll t;
ll K;
ll h, w;
string S, T;
cin >> t;
queue<ll> Q;
rep(i,t){
cin >> a;
if(a==1)
{
cin >> b;
Q.emplace(b);
}
else {
cout << Q.front() <<endl;
Q.pop();
}
}
}
Submission Info
| Submission Time |
|
| Task |
B - Restaurant Queue |
| User |
Syaku8 |
| Language |
C++ 20 (gcc 12.2) |
| Score |
200 |
| Code Size |
13736 Byte |
| Status |
AC |
| Exec Time |
4 ms |
| Memory |
3604 KiB |
Compile Error
Main.cpp: In function ‘bool operator>(const TRI&, const TRI&)’:
Main.cpp:343:28: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
343 | return (r.a > l.a | (r.a == l.a & r.b > l.b) |
| ~~~~^~~~~~
Main.cpp:343:15: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses]
343 | return (r.a > l.a | (r.a == l.a & r.b > l.b) |
| ~~~~^~~~~
Main.cpp:344:16: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
344 | (r.a == l.a & r.b == l.b & r.c > l.c));
| ~~~~^~~~~~
Main.cpp:344:42: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
344 | (r.a == l.a & r.b == l.b & r.c > l.c));
| ~~~~^~~~~
Main.cpp: In function ‘bool operator<(const TRI&, const TRI&)’:
Main.cpp:348:28: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
348 | return (r.a < l.a | (r.a == l.a & r.b < l.b) |
| ~~~~^~~~~~
Main.cpp:348:15: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses]
348 | return (r.a < l.a | (r.a == l.a & r.b < l.b) |
| ~~~~^~~~~
Main.cpp:349:16: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
349 | (r.a == l.a & r.b == l.b & r.c < l.c));
| ~~~~^~~~~~
Main.cpp:349:42: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
349 | (r.a == l.a & r.b == l.b & r.c < l.c));
| ~~~~^~~~~
Main.cpp: In constructor ‘UnionFind::UnionFind(size_t)’:
Main.cpp:445:20: warning: ‘UnionFind::m_parentsOrSize’ will be initialized after [-Wreorder]
445 | std::vector<int> m_parentsOrSize;
| ^~~~~~~~~~~~~~~
Main.cpp:444:7: warning: ‘int UnionFind::N’ [-Wreorder]
444 | int N;
| ^
Main.cpp:361:12: warning: when initialized here [-Wreorder]
361 | explicit UnionFind(size_t n)
| ^~~~~~~~~
Main.cpp:447:7: warning: ‘UnionFind::MAX’ will be initialized after [-Wreorder]
447 | vll MAX;
| ^~~
Main.cpp:446:7: warning: ‘vll UnionFind::MIN’ [-Wreorder]
446 | vll MIN;
| ^~~
Main.cpp:361:12: warning: when initialized here [-Wreorder]
361 | explicit UnionFind(size_t n)
| ^~~~~~~~~
Main.cpp:364:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
364 | for (int i = 0; i < n; i++)
| ~~^~~
Main.cpp: In function ‘void solve()’:
Main.cpp:457:6: warning: unused variable ‘a’ [-Wunused-variable]
457 | ll a = 0, b = 0;
| ^
Main.cpp:457:13: warning: unused variable ‘b’ [-Wunused-variable]
457 | ll a = 0, b = 0;
| ^
Main.cpp:458:6: warning: unused variable ‘a2’ [-Wunused-variable]
458 | ll a2, b2, c2;
| ^~
Main.cpp:458:10: warning: unused variable ‘b2’ [-Wunused-variable]
458 | ll a2, b2, c2;
| ^~
Main.cpp:458:14: warning: unused variable ‘c2’ [-Wunused-variable]
458 | ll a2, b2, c2;
| ^~
Main.cpp:459:6: warning: unused variable ‘a1’ [-Wunused-variable]
459 | ll a1 = 0, b1 = 0;
| ^~
Main.cpp:459:14: warning: unused variable ‘b1’ [-Wunused-variable]
459 | ll a1 = 0, b1 = 0;
| ^~
Main.cpp:460:6: warning: unused variable ‘c’ [-Wunused-variable]
460 | ll c = 0, c1;
| ^
Main.cpp:460:13: warning: unused variable ‘c1’ [-Wunused-variable]
460 | ll c = 0, c1;
| ^~
Main.cpp:461:6: warning: unused variable ‘p’ [-Wunused-variable]
461 | ll p = 0;
| ^
Main.cpp:462:6: warning: unused variable ‘N’ [-Wunused-variable]
462 | ll N, M;
| ^
Main.cpp:462:9: warning: unused variable ‘M’ [-Wunused-variable]
462 | ll N, M;
| ^
Main.cpp:463:6: warning: unused variable ‘t’ [-Wunused-variable]
463 | ll t;
| ^
Main.cpp:464:6: warning: unused variable ‘K’ [-Wunused-variable]
464 | ll K;
| ^
Main.cpp:465:6: warning: unused variable ‘h’ [-Wunused-variable]
465 | ll h, w;
| ^
Main.cpp:465:9: warning: unused variable ‘w’ [-Wunused-variable]
465 | ll h, w;
| ^
Main.cpp: In function ‘int main()’:
Main.cpp:498:6: warning: unused variable ‘a2’ [-Wunused-variable]
498 | ll a2, b2, c2;
| ^~
Main.cpp:498:10: warning: unused variable ‘b2’ [-Wunused-variable]
498 | ll a2, b2, c2;
| ^~
Main.cpp:498:14: warning: unused variable ‘c2’ [-Wunused-variable]
498 | ll a2, b2, c2;
| ^~
Main.cpp:499:6: warning: unused variable ‘a1’ [-Wunused-variable]
499 | ll a1 = 0, b1 = 0;
| ^~
Main.cpp:499:14: warning: unused variable ‘b1’ [-Wunused-variable]
499 | ll a1 = 0, b1 = 0;
| ^~
Main.cpp:500:6: warning: unused variable ‘c’ [-Wunused-variable]
500 | ll c = 0, c1;
| ^
Main.cpp:500:13: warning: unused variable ‘c1’ [-Wunused-variable]
500 | ll c = 0, c1;
| ^~
Main.cpp:501:6: warning: unused variable ‘p’ [-Wunused-variable]
501 | ll p = 0;
| ^
Main.cpp:502:6: warning: unused variable ‘N’ [-Wunused-variable]
502 | ll N, M;
| ^
Main.cpp:502:9: warning: unused variable ‘M’ [-Wunused-variable]
502 | ll N, M;
| ^
Main.cpp:504:6: warning: unused variable ‘K’ [-Wunused-variable]
504 | ll K;
| ^
Main.cpp:505:6: warning: unused variable ‘h’ [-Wunused-variable]
505 | ll h, w;
| ^
Main.cpp:505:9: warning: unused variable ‘w’ [-Wunused-variable]
505 | ll h, w;
| ^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
4 ms |
3568 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3548 KiB |
| 01_test_00.txt |
AC |
1 ms |
3440 KiB |
| 01_test_01.txt |
AC |
1 ms |
3396 KiB |
| 01_test_02.txt |
AC |
1 ms |
3496 KiB |
| 01_test_03.txt |
AC |
1 ms |
3492 KiB |
| 01_test_04.txt |
AC |
1 ms |
3480 KiB |
| 01_test_05.txt |
AC |
1 ms |
3480 KiB |
| 01_test_06.txt |
AC |
1 ms |
3396 KiB |
| 01_test_07.txt |
AC |
1 ms |
3432 KiB |
| 01_test_08.txt |
AC |
1 ms |
3548 KiB |
| 01_test_09.txt |
AC |
1 ms |
3448 KiB |
| 01_test_10.txt |
AC |
1 ms |
3604 KiB |
| 01_test_11.txt |
AC |
1 ms |
3480 KiB |
| 01_test_12.txt |
AC |
1 ms |
3480 KiB |
| 01_test_13.txt |
AC |
1 ms |
3444 KiB |
| 01_test_14.txt |
AC |
1 ms |
3484 KiB |
| 01_test_15.txt |
AC |
1 ms |
3504 KiB |
| 01_test_16.txt |
AC |
1 ms |
3496 KiB |
| 01_test_17.txt |
AC |
1 ms |
3488 KiB |
| 01_test_18.txt |
AC |
1 ms |
3492 KiB |
| 01_test_19.txt |
AC |
1 ms |
3436 KiB |
| 01_test_20.txt |
AC |
1 ms |
3432 KiB |
| 01_test_21.txt |
AC |
1 ms |
3484 KiB |