結果
問題 | No.2421 entersys? |
ユーザー | Nzt3 |
提出日時 | 2023-08-14 23:59:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 742 ms / 3,000 ms |
コード長 | 3,586 bytes |
コンパイル時間 | 3,239 ms |
コンパイル使用メモリ | 237,572 KB |
実行使用メモリ | 37,348 KB |
最終ジャッジ日時 | 2024-05-02 12:05:29 |
合計ジャッジ時間 | 15,854 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 5 ms
6,812 KB |
testcase_02 | AC | 4 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,940 KB |
testcase_05 | AC | 4 ms
6,940 KB |
testcase_06 | AC | 3 ms
6,944 KB |
testcase_07 | AC | 4 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 5 ms
6,944 KB |
testcase_10 | AC | 5 ms
6,940 KB |
testcase_11 | AC | 500 ms
30,796 KB |
testcase_12 | AC | 501 ms
31,456 KB |
testcase_13 | AC | 526 ms
30,872 KB |
testcase_14 | AC | 512 ms
30,788 KB |
testcase_15 | AC | 512 ms
31,320 KB |
testcase_16 | AC | 576 ms
33,732 KB |
testcase_17 | AC | 574 ms
33,200 KB |
testcase_18 | AC | 583 ms
33,980 KB |
testcase_19 | AC | 572 ms
33,560 KB |
testcase_20 | AC | 555 ms
33,664 KB |
testcase_21 | AC | 543 ms
33,644 KB |
testcase_22 | AC | 403 ms
29,772 KB |
testcase_23 | AC | 723 ms
37,348 KB |
testcase_24 | AC | 742 ms
36,344 KB |
testcase_25 | AC | 735 ms
36,568 KB |
testcase_26 | AC | 246 ms
25,952 KB |
testcase_27 | AC | 255 ms
25,792 KB |
testcase_28 | AC | 253 ms
25,788 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/lazysegtree> using namespace std; using ll=long long; struct query{ int t=-2; string name=""; int l=-1,r=-1,q_time=-1; }; int segtree_op(int a,int b){ return a+b; } int segtree_e(){ return 0; } int segtree_add(int a,int b){ return a+b; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector<pair<string,array<int,2>>> base_info(N); vector<int>time_comp; for(auto &i:base_info){ cin>>i.first>>i.second[0]>>i.second[1]; time_comp.push_back(i.second[0]); time_comp.push_back(i.second[1]); } int Q; cin>>Q; vector<query>Query_list; for(int i=0;i<Q;i++){ int T; cin>>T; query a; a.t=T; if(T==1){ cin>>a.name; cin>>a.q_time; time_comp.push_back(a.q_time); }else if(T==2){ cin>>a.q_time; time_comp.push_back(a.q_time); }else{ cin>>a.name; cin>>a.l>>a.r; time_comp.push_back(a.l); time_comp.push_back(a.r); } Query_list.push_back(a); } map<string,int>name2idx; for(int i=0;i<N;i++){ string name=base_info[i].first; if(name2idx.find(name)==name2idx.end()){ int x=name2idx.size(); name2idx[name]=x; } } for(int i=0;i<Q;i++){ string name=Query_list[i].name; if(name=="")continue; if(name2idx.find(name)==name2idx.end()){ int x=name2idx.size(); name2idx[name]=x; } } sort(time_comp.begin(),time_comp.end()); time_comp.erase(unique(time_comp.begin(),time_comp.end()),time_comp.end()); auto time2idx =[&](int n){ return (int)(lower_bound(time_comp.begin(),time_comp.end(),n)-time_comp.begin()); }; // time / (0:i|1:check|2:out) / info_time(query index) vector<vector<array<int,3>>>human_timelist(name2idx.size()); for(int i=0;i<N;i++){ human_timelist[name2idx[base_info[i].first]].push_back({time2idx(base_info[i].second[0]),0,-1}); human_timelist[name2idx[base_info[i].first]].push_back({time2idx(base_info[i].second[1]),2,-1}); } for(int i=0;i<Q;i++){ if(Query_list[i].t==1){ human_timelist[name2idx[Query_list[i].name]].push_back({time2idx(Query_list[i].q_time),1,i}); }else if(Query_list[i].t==3){ human_timelist[name2idx[Query_list[i].name]].push_back({time2idx(Query_list[i].l),0,i}); human_timelist[name2idx[Query_list[i].name]].push_back({time2idx(Query_list[i].r),2,i}); } } vector<int>ans(Q); for(int i=0;i<name2idx.size();i++){ int time_n=-2; sort(human_timelist[i].begin(),human_timelist[i].end()); for(int j=0;j<human_timelist[i].size();j++){ if(human_timelist[i][j][1]==1){ if(time_n>=-1&&time_n<human_timelist[i][j][2]){ ans[human_timelist[i][j][2]]=1; }else{ ans[human_timelist[i][j][2]]=0; } }else if(human_timelist[i][j][1]==0){ time_n=human_timelist[i][j][2]; }else if(human_timelist[i][j][1]==2){ time_n=-2; } } } atcoder::lazy_segtree<int,segtree_op,segtree_e,int,segtree_op,segtree_op,segtree_e> count_human((int)time_comp.size()+10); for(int i=0;i<N;i++){ count_human.apply(time2idx(base_info[i].second[0]),time2idx(base_info[i].second[1])+1,1); } for(int i=0;i<Q;i++){ auto q=Query_list[i]; if(q.t==2){ ans[i]=count_human.get(time2idx(q.q_time)); }else if(q.t==3){ count_human.apply(time2idx(q.l),time2idx(q.r)+1,1); } } for(int i=0;i<Q;i++){ if(Query_list[i].t==1){ cout<<(ans[i]?"Yes\n":"No\n"); }else if(Query_list[i].t==2){ cout<<ans[i]<<'\n'; } } }