提出 #59942515
ソースコード 拡げる
// Photon in a double-slit !!
#include <bits/stdc++.h>
#define ffr(i, a, b) for (int i = (a); i <= (b); i++)
#define rff(i, a, b) for (int i = (a); i >= (b); i--)
#define fr(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define ppb pop_back
#define ppf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a, b) memset(a, b, sizeof(a))
#define runtime() ((double)clock() / CLOCKS_PER_SEC)
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long
// #undef TRACE
// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)enum name
{
};
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args)
{
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<vi> graph;
template <class T>
void mxi(T &a, const T &b) { a = max(a, b); }
template <class T>
void mni(T &a, const T &b) { a = min(a, b); }
ld EPS = 1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
#define SHUF(v) shuffle(all(v), RNG);
void show(vi arr){for(auto x: arr){cout<<x<<" ";}cout<<endl;}
ll binpow(ll a, ll b){ll res=1;while(b!=0){if(b&1)res*=a;a*=a;b>>=1;}return res;}
ll binpow(ll a, ll b, ll md){ll res=1;a%=md;if(a==0)return 0;while(b!=0){if(b&1)res*=a,res%=md;a*=a,a%=md;b>>=1;}return res%md;}
// Use mt19937_64 for 64 bit random numbers.
void solve()
{
int n,q; cin>>n>>q;
set<int> st;
vector<int> arr(n+1,0), cnt(n+1,0);
for(int i = 1; i<=n; i++){
st.in(i);
arr[i]=i;
cnt[i]=1;
}
while(q--){
int a; cin>>a;
if(a==1){
int x,c; cin>>x>>c;
int prev = n+1;
// debug(st);
while(!st.empty() && (*st.rbegin())>=x){
auto b = *st.rbegin();
cnt[arr[b]]-=(prev-b);
prev = b;
st.erase(st.find(b));
}
if(!st.empty()){
auto b = *st.rbegin();
cnt[arr[b]]-=(prev-x);
}
arr[x]=c;
cnt[c]+=(n-x+1);
st.in(x);
debug(cnt);
}else{
int c; cin>>c;
cout<<cnt[c]<<endl;
}
}
}
void init(){
fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
init();
int _t, tab;
_t=1;
// cin >> _t;
tab = _t;
while (_t--)
{
//cout<<"Case #"<<(tab -_t)<<": ";
solve();
}
#ifdef TRACE
cerr << runtime();
#endif
}
提出情報
| 提出日時 |
|
| 問題 |
E - 1D Bucket Tool |
| ユーザ |
crompton |
| 言語 |
C++ 20 (gcc 12.2) |
| 得点 |
0 |
| コード長 |
4523 Byte |
| 結果 |
WA |
| 実行時間 |
194 ms |
| メモリ |
34624 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:147:13: warning: variable ‘tab’ set but not used [-Wunused-but-set-variable]
147 | int _t, tab;
| ^~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 450 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt |
| All |
hand.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, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| hand.txt |
AC |
1 ms |
3480 KiB |
| random_01.txt |
AC |
19 ms |
3492 KiB |
| random_02.txt |
WA |
20 ms |
3492 KiB |
| random_03.txt |
WA |
19 ms |
3548 KiB |
| random_04.txt |
WA |
18 ms |
3520 KiB |
| random_05.txt |
WA |
148 ms |
34484 KiB |
| random_06.txt |
WA |
194 ms |
34488 KiB |
| random_07.txt |
WA |
166 ms |
34532 KiB |
| random_08.txt |
WA |
156 ms |
34464 KiB |
| random_09.txt |
WA |
158 ms |
34464 KiB |
| random_10.txt |
WA |
155 ms |
34468 KiB |
| random_11.txt |
WA |
165 ms |
34624 KiB |
| random_12.txt |
WA |
170 ms |
34392 KiB |
| random_13.txt |
WA |
35 ms |
6240 KiB |
| random_14.txt |
WA |
34 ms |
6232 KiB |
| random_15.txt |
WA |
34 ms |
6376 KiB |
| random_16.txt |
WA |
35 ms |
6316 KiB |
| sample_01.txt |
AC |
1 ms |
3496 KiB |