Submission #66725642
Source Code Expand
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
using mint = static_modint<998244353>;
using namespace std;
istream& operator>>(istream& is, mint a) {
long long v;
is >> v;
a = v;
return is;
}
ostream& operator<<(ostream& os, mint a) {
return os << a.val();
}
#endif
using namespace std;
template<typename T>
using vec = vector<T>;
using ll = long long;
using ull = unsigned long long;
using vi = vec<int>;
using vs = vec<string>;
using si = set<int>;
using sll = set<ll>;
using vc = vec<char>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using vll = vec<ll>;
using vvll = vec<vll>;
using vvvll = vec<vvll>;
using vsi = vec<si>;
using vsll = vec<sll>;
using vd = vec<double>;
using vvd = vec<vd>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using msi = map<string, int>;
using vpii = vec<pii>;
using vvpii = vec<vpii>;
using vpll = vec<pll>;
using vvpll = vec<vpll>;
using spii = set<pii>;
using spll = set<pll>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,j,n) for(ll i=j;i<(n);i++)
#define rrep(i,j,n) for (ll i = (n)-1; i >=j; i--)
#define rp(i,n) rep(i,0,(n))
#define rrp(i,n) rrep(i,0,(n))
#define all(v) v.begin(), v.end()
#define pb push_back
#define ins insert
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define yn(jg) cout<<((jg)? "Yes":"No")<<endl;
#define NL {cout<<endl;}
#define n0 {cout<<"-1"<<endl;}
#define lwb lower_bound
#define upb upper_bound
template<typename T>
int len(T& x) { return int(x.size()); }
#define sz size()
#define fi first
#define se second
#define nxp next_permutation
ll mod0 = 998244353, lmax = 4e18, inf = 1050000000;
double pi = 3.141592653589793238462643;
vll vh = { 998244353, 998244853, 1000000007, 1000000009, 1012924417 };
template<typename... T>
void in(T&... X) { (cin >> ... >> X); }
template<typename T>
void ain(vec<T>& Y) { rp(K, Y.size()) cin >> Y[K]; }
template<typename T>
void ain(set<T>& Y, auto n) {
rp(i, n) {
T YY; cin >> YY;
Y.insert(YY);
}
}
template<typename T>
void ain(multiset<T>& Y, auto n) {
rp(i, n) {
T YY; cin >> YY;
Y.insert(YY);
}
}
template<typename T>
void ain(pair<T, T>& a) { cin >> a.fi >> a.se; }
template<typename T>
void bin(vec<T>& Z) { rp(L, Z.size()) ain(Z[L]); }
template <typename T>struct is_vector : std::false_type {};
template <typename T, typename Alloc>struct is_vector<std::vector<T, Alloc>> : std::true_type {};
template <typename T>struct is_queue : std::false_type {};
template <typename T, typename Container>struct is_queue<std::queue<T, Container>> : std::true_type {};
template <typename T>struct is_stack : std::false_type {};
template <typename T, typename Container>struct is_stack<std::stack<T, Container>> : std::true_type {};
template <typename T>struct is_pair : std::false_type {};
template <typename T1, typename T2>struct is_pair<std::pair<T1, T2>> : std::true_type {};
template <typename T>
void aout(const T& x) {
if constexpr (is_vector<T>::value) {
for (const auto& element : x) {
aout(element); // 再帰的に処理
}
cout << endl;
}
else if constexpr (is_queue<T>::value) {
auto copy = x; // std::queue をコピーして処理(元のキューを破壊しないため)
while (!copy.empty()) {
aout(copy.front());
copy.pop();
}
cout << endl;
}
else if constexpr (is_stack<T>::value) {
auto copy = x; // std::stack をコピーして処理(元のスタックを破壊しないため)
while (!copy.empty()) {
aout(copy.top());
copy.pop();
}
cout << endl;
}
else if constexpr (is_pair<T>::value) {
aout(x.first);
aout(x.second);
cout << endl;
}
else {
std::cout << x << " ";
}
}
template<typename T>
bool chmin(T& M1, T M2) {
if (M1 > M2) { M1 = M2; return 1; }
else return 0;
}
template<typename T>
bool chmax(T& M1, T M2) {
if (M1 < M2) { M1 = M2; return 1; }
else return 0;
}
template<typename T>
auto vmax(T& a) {
return *max_element(all(a));
}
template<typename T>
auto vmin(T& a) {
return *min_element(all(a));
}
template<typename T>
auto vmaxi(T& a) {
return max_element(all(a)) - a.begin();
}
template<typename T>
auto vmini(T& a) {
return min_element(all(a)) - a.begin();
}
template<typename T>
auto vsum(vector<T> a) {
T x = 0;
for (auto i : a)x += i;
return x;
}
ll dsum(ll a) {//桁和
ll r = 0;
while (a != 0) {
r += a % 10;
a /= 10;
}
return r;
}
ll dnum(ll a) {//桁数(0は0桁)
ll r = 0;
while (a != 0) {
r++;
a /= 10;
}
return r;
}
vector<pair<char, ll>> rle(string rr) {
vector<pair<char, ll>> ret;
char lc;
rep(i, 0, rr.size()) {
if (i > 0 && rr[i] == lc) ret[ret.sz - 1].second++;
else { ret.pb({ rr[i],1 }); }
lc = rr[i];
}
return ret;
}
vector<pair<int, ll>> rle(vi rr) {
vector<pair<int, ll>> ret;
int lc;
rep(i, 0, rr.size()) {
if (i > 0 && rr[i] == lc) ret[ret.sz - 1].second++;
else { ret.pb({ rr[i],1 }); }
lc = rr[i];
}
return ret;
}
vector<pair<ll, ll>> rle(vll rr) {
vector<pair<ll, ll>> ret;
ll lc;
rep(i, 0, rr.size()) {
if (i > 0 && rr[i] == lc) ret[ret.sz - 1].second++;
else { ret.pb({ rr[i],1 }); }
lc = rr[i];
}
return ret;
}
ll ds2(ll x1, ll x2, ll y1, ll y2) {//distの2乗(整数値)
return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
template<typename T>
ll ds2(vec<T> a) {
return (a[0] - a[2]) * (a[0] - a[2]) + (a[1] - a[3]) * (a[1] - a[3]);
}
template<typename T>
auto lwa(vector<T>& a, T b) {//aでbより小さい最大の値のイテレータ(複数あれば右端)
auto i = lwb(all(a), b);
if (i == a.begin()) return a.end();
else i--;
return i;
}
template<typename T>
auto lwa(set<T>& a, T b) {//aでbより小さい最大の値のイテレータ
auto i = a.lwb(b);
if (i == a.begin()) return a.end();
else i--;
return i;
}
template<typename T>
auto lwa(multiset<T>& a, T b) {//aでbより小さい最大の値のイテレータ
auto i = a.lwb(b);
if (i == a.begin()) return a.end();
else i--;
return i;
}
template<typename T>
auto lwc(vector<T>& a, T b) {//aでb以下の最大の値のイテレータ(複数あれば左端)
auto i = lwb(all(a), b);
if (i != a.end() && *i == b) return i;
if (i == a.begin()) return a.end();
else i--;
return i;
}
template<typename T>
auto lwc(set<T>& a, T b) {//aでb以下の最大の値のイテレータ
auto i = a.lwb(b);
if (i != a.end() && *i == b) return i;
if (i == a.begin()) return a.end();
else i--;
return i;
}
template<typename T>
auto lwc(multiset<T>& a, T b) {//aでb以下の最大の値のイテレータ
auto i = a.lwb(b);
if (i != a.end() && *i == b) return i;
if (i == a.begin()) return a.end();
else i--;
return i;
}
template <typename T>
std::pair<typename vector<T>::iterator, typename vector<T>::iterator> its(vec<T>& v, T a) {//前後のイテレータのpair返す(なければend())
auto it = lwb(all(v), a);
if (it == v.begin()) return { v.end(), it };
auto it2 = it; it2--;
return { it2,it };
}
template <typename T>
std::pair<typename set<T>::iterator, typename set<T>::iterator> its(set<T>& v, T a) {
auto it = lwb(all(v), a);
if (it == v.begin()) return { v.end(), it };
auto it2 = it; it2--;
return { it2,it };
}
template<typename T>
vec<T> rsw(vec<T>& a) {//累積和
vec<T> b = { 0 };
rp(i, a.sz) b.pb(a[i] + b[b.sz - 1]);
return b;
}
bool kai(string S) {//回文か判定
bool ans = 1;
rp(i, S.size()) if (S[i] != S[S.size() - 1 - i]) ans = 0;
return ans;
}
sll yk(ll n) {//約数全列挙O(sqrt(N)),set<int>
sll yaku;
for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
yaku.insert(i);
yaku.insert(n / i);
}
return yaku;
}
vi ssa(int n) {//n:必要な素数の最大値 素数全列挙
vector<int> prime;
vector<int>lpf(n + 1, 0);
rep(i, 2, n + 1) {
if (lpf[i] == 0) {
lpf[i] = i;
prime.push_back(i);
}
for (int k : prime) {
if (k * i > n || k > lpf[i]) break;//k最小素因数よりk<=i
lpf[k * i] = k;//kを最小素因数に持つ数k*iを拾う
}
}
return prime;
}
vector<pll> sib(ll x) {//素因数分解
if (x == 1) return vector<pll>(1, { 1,1 });
vector<pll> ans;
for (ll i = 2; i * i <= x; i++) {//rootx回iを回しxで割る
ll kaisu = 0;
while (x % i == 0) {
x /= i; kaisu++;
}
if (kaisu > 0) ans.pb({ i,kaisu });
}
if (x != 1) ans.pb({ x,1 });
return ans;
}
template<typename T>
vec<T> zat(vec<T> a) {//座標圧縮
auto b = a;
sort(all(b));
b.erase(unique(all(b)), b.end());
vec<T> c(a.size());
rp(i, a.size()) {
c[i] = lwb(all(b), a[i]) - b.begin();
}
return c;
}
template<typename T>
void cp(map < T, ll >& a, T b, ll c) {//countplus
if (a.find(b) == a.end()) a[b] = c;
else a[b] += c;
if (a[b] == 0) a.erase(b);
}
template<typename T>
vec<T> inv(vec<T> a) {//0-indexed 逆関数
vec<T> ans(a.sz);
rp(i, a.sz) {
ans[a[i]] = i;
}
return ans;
}
template<typename T>
vec<T> inv1(vec<T> a) {//1-indexed
vec<T> ans(a.sz);
rp(i, a.sz) {
ans[a[i] - 1] = i + 1;
}
return ans;
}
vvll hs(string s) {//stringからhashの表
vvll r(s.sz + 1, vll(3, 0));
rp(i, s.sz) {
rp(j, 3) {
r[i + 1][j] = r[i][j] * 27;
r[i + 1][j] += (s[i] - 'a' + 1);
r[i + 1][j] %= vh[j];
}
}
return r;
}
bool hssame(vvll& hs1, ll l1, ll r1, vvll& hs2, ll l2, ll r2, vll szp) {//hashがhs1の文字列の[l1,r1)とhs2の文字列の[l2,r2)が同じか判定 szp={27^(r1 - l1)}
assert(0 <= l1); assert(l1 <= r1); assert(r1 < hs1.sz);
assert(0 <= l2); assert(l2 <= r2); assert(r2 < hs2.sz);
vll t1(3, 0), t2(3, 0);
rp(j, 3) t1[j] = (hs1[r1][j] - hs1[l1][j] * szp[j] % vh[j] + vh[j]) % vh[j];
rp(j, 3) t2[j] = (hs2[r2][j] - hs2[l2][j] * szp[j] % vh[j] + vh[j]) % vh[j];
return t1 == t2;
}
template<typename T>
bool cross(T a, T b, T c, T d) {//区間(a,b)と区間(c,d)が重なるか判定
return !(b <= c || d <= a);
}
template<typename T>
bool crosse(T a, T b, T c, T d) {//区間[a,b]と区間[c,d]が重なるか判定
return !(b < c || d < a);
}
template<typename T>
vec<vll> absort(vec<T> a, vec<T> b) {//l,rのl昇順r逆順sort
vec<vec<T>> ab(a.sz);
rp(i, a.sz) ab[i] = { a[i],-b[i],i };
sort(all(ab));
rp(i, a.sz) ab[i][1] = -ab[i][1];
return ab;
}
template<typename T>
bool rabc(T a, T b, T c) {//円環状でa,b,cがこの順か判定 同じ値はfalse
return ((a - b) / abs(a - b)) * ((b - c) / abs(b - c)) * ((c - a) / abs(c - a)) > 0;
}
template<typename T>
bool labc(T a, T b, T c) {//a<=b<cか判定
return a <= b && b < c;
}
template<typename T>
ll Sqrt(T a) {//整数sqrt
assert(a >= 0);
ll r = sqrt(a);
while (r * r > a) r--;
while ((r + 1) * (r + 1) <= a) r++;
return r;
}
ll powll(ll a, ll b) {//llでpow
ll c = 1;
assert(pow(a, b) <= 9e18);
rp(i, b) {
c *= a;
}
return c;
}
//lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
//S:中身型 op:左右合成 e:初期値
//F:遅延型 mapping:遅延適用後の要素 composition:遅延合成( 関数f(g()) ) id:遅延初期値(何もさせない)
using S = ll;
using F = ll;
S op(S a, S b) {
return max(a,b);
}
S e() {
return 0;
}
/*
S mapping(F x, S a) {//xをaに作用(x初期値に注意)
if (x != lmax)return { x * a.se,a.se };
else return a;
}
F composition(F f, F g) {//fの方が後(f初期値に注意)
if (f != lmax)return f;
else return g;
}
F id() { return lmax; }*/
//cout<<setprecision(15)<<fixed<<
//function<返り値の型(引数の型1, 引数の型2, ...)> 関数名 = [&](引数の型1 引数名1, 引数の型2, 引数名2, ...)
int main(){
int n,q;
cin>>n>>q;
vi x(q);ain(x);
vi xx(n,0);
rp(i,q){
if(x[i]!=0) {
xx[x[i]-1]++;
cout<<x[i]<<" ";
}
else{int mn=1000,mnb=0;
rp(ii,n){
if(chmin(mn,xx[ii])) mnb=ii;
}
xx[mnb]++;
cout<<mnb+1<<" ";
}
}
}
Submission Info
| Submission Time |
|
| Task |
B - Reverse Proxy |
| User |
syun0713 |
| Language |
C++ 23 (gcc 12.2) |
| Score |
200 |
| Code Size |
12160 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3720 KiB |
Compile Error
Main.cpp:1: warning: ignoring ‘#pragma warning ’ [-Wunknown-pragmas]
1 | #pragma warning(disable:4996)
|
Main.cpp: In function ‘std::vector<std::pair<char, long long int> > rle(std::string)’:
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:187:9: note: in expansion of macro ‘rep’
187 | rep(i, 0, rr.size()) {
| ^~~
Main.cpp: In function ‘std::vector<std::pair<int, long long int> > rle(vi)’:
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:197:9: note: in expansion of macro ‘rep’
197 | rep(i, 0, rr.size()) {
| ^~~
Main.cpp: In function ‘std::vector<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > > rle(vll)’:
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:207:9: note: in expansion of macro ‘rep’
207 | rep(i, 0, rr.size()) {
| ^~~
Main.cpp: In function ‘bool kai(std::string)’:
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:52:17: note: in expansion of macro ‘rep’
52 | #define rp(i,n) rep(i,0,(n))
| ^~~
Main.cpp:288:9: note: in expansion of macro ‘rp’
288 | rp(i, S.size()) if (S[i] != S[S.size() - 1 - i]) ans = 0;
| ^~
Main.cpp: In function ‘vvll hs(std::string)’:
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:52:17: note: in expansion of macro ‘rep’
52 | #define rp(i,n) rep(i,0,(n))
| ^~~
Main.cpp:364:9: note: in expansion of macro ‘rp’
364 | rp(i, s.sz) {
| ^~
In file included from /usr/include/c++/12/cassert:44,
from /opt/ac-library/atcoder/twosat.hpp:4,
from /opt/ac-library/atcoder/twosat:1,
from /opt/ac-library/atcoder/all:12,
from Main.cpp:4:
Main.cpp: In function ‘bool hssame(vvll&, ll, ll, vvll&, ll, ll, vll)’:
Main.cpp:374:54: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<std::vector<long long int>, std::allocator<std::vector<long long int> > >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
374 | assert(0 <= l1); assert(l1 <= r1); assert(r1 < hs1.sz);
| ^
Main.cpp:375:54: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<std::vector<long long int>, std::allocator<std::vector<long long int> > >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
375 | assert(0 <= l2); assert(l2 <= r2); assert(r2 < hs2.sz);
| ^
Main.cpp: In instantiation of ‘void ain(vec<T>&) [with T = int; vec<T> = std::vector<int>]’:
Main.cpp:449:13: required from here
Main.cpp:50:32: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | #define rep(i,j,n) for(ll i=j;i<(n);i++)
| ^
Main.cpp:52:17: note: in expansion of macro ‘rep’
52 | #define rp(i,n) rep(i,0,(n))
| ^~~
Main.cpp:76:23: note: in expansion of macro ‘rp’
76 | void ain(vec<T>& Y) { rp(K, Y.size()) cin >> Y[K]; }
| ^~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt |
| Case Name |
Status |
Exec Time |
Memory |
| sample_01.txt |
AC |
1 ms |
3560 KiB |
| sample_02.txt |
AC |
1 ms |
3512 KiB |
| sample_03.txt |
AC |
1 ms |
3524 KiB |
| test_01.txt |
AC |
1 ms |
3540 KiB |
| test_02.txt |
AC |
1 ms |
3480 KiB |
| test_03.txt |
AC |
1 ms |
3652 KiB |
| test_04.txt |
AC |
1 ms |
3648 KiB |
| test_05.txt |
AC |
1 ms |
3492 KiB |
| test_06.txt |
AC |
1 ms |
3544 KiB |
| test_07.txt |
AC |
1 ms |
3576 KiB |
| test_08.txt |
AC |
1 ms |
3564 KiB |
| test_09.txt |
AC |
1 ms |
3652 KiB |
| test_10.txt |
AC |
1 ms |
3568 KiB |
| test_11.txt |
AC |
1 ms |
3580 KiB |
| test_12.txt |
AC |
1 ms |
3608 KiB |
| test_13.txt |
AC |
1 ms |
3556 KiB |
| test_14.txt |
AC |
1 ms |
3720 KiB |
| test_15.txt |
AC |
1 ms |
3572 KiB |
| test_16.txt |
AC |
1 ms |
3604 KiB |
| test_17.txt |
AC |
1 ms |
3640 KiB |
| test_18.txt |
AC |
1 ms |
3552 KiB |
| test_19.txt |
AC |
1 ms |
3548 KiB |
| test_20.txt |
AC |
1 ms |
3616 KiB |
| test_21.txt |
AC |
1 ms |
3552 KiB |
| test_22.txt |
AC |
1 ms |
3568 KiB |
| test_23.txt |
AC |
1 ms |
3556 KiB |
| test_24.txt |
AC |
1 ms |
3556 KiB |
| test_25.txt |
AC |
1 ms |
3640 KiB |
| test_26.txt |
AC |
1 ms |
3508 KiB |
| test_27.txt |
AC |
1 ms |
3592 KiB |
| test_28.txt |
AC |
1 ms |
3540 KiB |
| test_29.txt |
AC |
1 ms |
3560 KiB |
| test_30.txt |
AC |
1 ms |
3580 KiB |
| test_31.txt |
AC |
1 ms |
3556 KiB |
| test_32.txt |
AC |
1 ms |
3652 KiB |
| test_33.txt |
AC |
1 ms |
3548 KiB |
| test_34.txt |
AC |
1 ms |
3516 KiB |
| test_35.txt |
AC |
1 ms |
3644 KiB |
| test_36.txt |
AC |
1 ms |
3564 KiB |
| test_37.txt |
AC |
1 ms |
3568 KiB |
| test_38.txt |
AC |
1 ms |
3564 KiB |
| test_39.txt |
AC |
1 ms |
3592 KiB |