QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589503 | #8230. Submissions | NTT | WA | 71ms | 4088kb | C++23 | 9.7kb | 2024-09-25 18:12:09 | 2024-09-25 18:12:09 |
Judging History
answer
#pragma GCC optimize("Ofast,inline,unroll-loops")
#ifdef GTRAKIOI
#define _GLIBCXX_DEBUG //交题前记得注释掉不然容易T。
#endif
#include<bits/stdc++.h>
// #include<stdio.h>
#define File(s) freopen(#s".in","r",stdin),freopen(#s".out","w",stdout)
#ifdef GTRAKIOI
#include"C:/code/deb_20.cpp"
#define defrog(...) fprintf(stderr,__VA_ARGS__)
#define deb(x) (std::cerr<<#x<<"@"<<__LINE__<<"="<<(x)<<'\n')
#else
#define defrog(...) 1
#define deb(x) 1
#define debug(...) 1
#define debugArr(...) 1
#endif
#define defrogf(...) defrog(__VA_ARGS__)
#define Tp template<typename T>
#define Tl template<typename T
#define Tr >
#define IS(cond) ,std::enable_if_t<(cond), int> = 0
#if __cplusplus>=201703L
#define register
#endif
#ifdef _MSC_VER
#if __has_include(<__msvc_int128.hpp>)
#include <__msvc_int128.hpp> // https://stackoverflow.com/a/76440171
#define __int128 std::_Signed128
#define __int128_t std::_Signed128
#define __uint128_t std::_Unsigned128
#define __SIZEOF_INT128__ 16
#endif
#endif
using ll=long long;
using ull=unsigned long long;
#ifdef __SIZEOF_INT128__
using lll=__int128;
// using ulll=unsigned __int128;
#endif
using db=double;
using ld=long double;
#define INT_ALIAS(w) using i##w=std::int##w##_t;using u##w=std::uint##w##_t;
INT_ALIAS(8) INT_ALIAS(16) INT_ALIAS(32) INT_ALIAS(64)
#ifdef __SIZEOF_INT128__
using i128=__int128_t;
using u128=__uint128_t;
using i7=__int128_t;
using u7=__uint128_t;
template <class T>
using to_unsigned = typename std::conditional<
std::is_same<T, __int128_t>::value ||
std::is_same<T, __int128>::value,
std::common_type<__uint128_t>,
typename std::conditional<std::is_signed<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type>::type;
#else
template <class T>
using to_unsigned = std::make_unsigned<T>;
#endif
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
template<typename T>using vv=std::vector<T>;
template<typename T>using V=std::vector<T>;
using pii=std::pair<int,int>;
using vi=V<int>;
using vll=V<ll>;
using vpii=V<pii>;
using vvi=V<vi>;
template<typename T>using pq=std::priority_queue<T>;
template<typename T>using pqg=std::priority_queue<T,std::vector<T>,std::greater<>>;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define all(cont) std::begin(cont),std::end(cont)
char ibuf[1<<15],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=ibuf)+fread(ibuf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
struct FastIO{
Tl IS(!std::numeric_limits<T>::is_signed) Tr inline void oint(T x){
T y=1;
while(y<=x/10)y*=10;
do putchar(int(x/y)|48),x%=y,y/=10;while(y);
}
Tl IS(std::numeric_limits<T>::is_signed) Tr inline void oint(const T&x){
if(x<0){
putchar('-');
oint<to_unsigned_t<T>>(-x);
}else oint<to_unsigned_t<T>>(x);
}
Tl=int IS(std::numeric_limits<T>::is_integer) Tr inline T rint(){register char c,f=0;while((c=getchar())<48||c>57)f|=c=='-';to_unsigned_t<T> a=c&15;while((c=getchar())>=48&&c<=57)a=a*10+(c&15);return f?~a+1:a;}
// inline ll rll(){rg char c,f=0;while((c=getchar())<48||c>57)f|=c=='-';rg ull a=c&15;while((c=getchar())>=48&&c<=57)a=a*10+(c&15);return f?~a+1:a;}
// inline operator int(){return rint();}
// inline operator ll(){return rll();}
Tl IS(std::numeric_limits<T>::is_integer) Tr inline operator T(){return rint<T>();}
inline char rchar(){register char c;while(!isgraph(c=getchar()));return c;}
inline int rstr(char*s){register char c;while(!isgraph(c=getchar()));int cnt=-1;do s[++cnt]=c;while(isgraph(c=getchar()));s[++cnt]=0;return cnt;}
inline std::string rs(){register char c;while(!isgraph(c=getchar()));std::string s;do s+=c;while(isgraph(c=getchar()));return s;}
Tl IS(std::numeric_limits<T>::is_integer) Tr inline void print(const T&x){oint(x);}
inline void print(const char&x){putchar(x);}
inline void print(const char*const&x){for(int i=0;x[i];++i)putchar(x[i]);}
#if __cplusplus >= 202002L
Tp requires std::ranges::range<T> inline void print(const T&c){
bool first=true;
for(const auto&x:c){
if(!first)putchar(' ');
first=false;
print(x);
}
}
#endif
inline void print(const std::string&x){for(int i=0;x[i];++i)putchar(x[i]);}
// print with separators
// inline void prints(){putchar('\n');}
// inline void prints(const auto&x,const auto&...rst){print(x),putchar(' '),prints(rst...);}
inline void prints(const auto&...x){((print(x),putchar(' ')),...);putchar('\n');}
}g90;
inline void YON(const bool&x){puts(x?"YES":"NO");}
inline void Yon(const bool&x){puts(x?"Yes":"No");}
inline void yon(const bool&x){puts(x?"yes":"no");}
template<typename T=int>std::vector<T>rvec(std::size_t n,std::size_t start=0) {
std::vector<T>res(start+n);
for(std::size_t i=start;i<start+n;++i)res[i]=g90;
return res;
}
std::mt19937 rng(u32(std::chrono::high_resolution_clock::now().time_since_epoch().count()));
Tl IS(std::is_floating_point<T>::value) Tr inline T rnd(const T&a,const T&b){
return std::uniform_real_distribution<T>(a,b)(rng);
}
Tl IS(std::numeric_limits<T>::is_integer) Tr inline T rnd(const T&a,const T&b){
return std::uniform_int_distribution<T>(a,b)(rng);
}
namespace MY_STD{
Tp inline T abs(const T&a){return a<0?-a:a;}
}
#if __cplusplus >= 202002L
namespace all{
using namespace std::ranges;
using namespace std::views;
//ambiguous ones
using std::views::iota;
using std::views::empty;
using std::views::reverse;
inline constexpr auto&R=std::views::reverse;
}
#endif
struct DSU{//unweighted
using key_type=int;
std::vector<key_type>fa,size;
inline DSU(key_type n):fa(n),size(n,1){std::iota(fa.begin(),fa.end(),0);}
inline key_type& getFa(key_type x){
while(x^fa[x])x=fa[x]=fa[fa[x]];
return fa[x];
}
inline key_type& operator[](const key_type&x){return getFa(x);}
inline auto canMerge(const key_type&u,const key_type&v){return getFa(u)!=getFa(v);}
inline bool merge(key_type u,key_type v){
u=getFa(u),v=getFa(v);
return (u)!=(v)&&(size[u]<size[v]&&(std::swap(u,v),1),fa[v]=u,size[u]+=size[v],size[v]=0,true);
}
};
template<typename Compare=std::less<>>inline bool ckmax(auto& a,const auto& b,const Compare&comp={}){return comp(a,b)?(a=b,true):false;}
template<typename Compare=std::less<>>inline bool ckmin(auto& a,const auto& b,const Compare&comp={}){return comp(b,a)?(a=b,true):false;}
inline auto divf(const auto&a,const auto&b){//assume b>0
return a<0?(a+1)/b-1:a/b;
}
inline auto divc(const auto&a,const auto&b){//assume b>0
return a>0?(a-1)/b+1:a/b;
}
constexpr int N=-2024,M=1;//1000000007;
inline int qpow(ll a,auto b){int res=1;for(;b;a=a*a%M,b>>=1)if(b&1)res=res*a%M;return res;}
// #define pow qpow
struct S{
int bel,p,t,s;
};
signed main(){
using std::cin,std::cout,std::cerr;
//std::ios::sync_with_stdio(0);std::cin.tie(0);std::cout.tie(0);
int T=1;
T=g90;
for(;T--;)[&]{
std::map<std::string,int>id;
std::map<int,std::string>name;
int m=g90;
vvi solved(m,vi(27,300));
V<S>subl(m);
V sub(m,V<V<pii>>(27));
for(auto&&[bel,p,t,s]:subl){
std::string x=g90.rs();
if(!id.count(x)){
name[id[x]=id.size()]=x;
}
bel=id[x];
p=g90.rchar()&31;
t=g90;
x=g90.rs();
s=x[0]=='a';
sub[bel][p].eb(t,s);
}
int N=ssize(id);
solved.resize(N);
sub.resize(N);
auto calc=[&](int c){
std::array<std::array<int,2>,3>gra={};
V<std::array<int,2>> q[3];
for(int p=1;p<=26;++p)if(!sub[c][p].empty()){
int flag=0;
int a[3]={},b[3]={};
a[0]=-1;
b[0]=sub[c][p].front().first;
int cnt=0;
for(auto&&[t,s]:sub[c][p]){
if(s){
++flag;
if(flag>2)break;
a[flag]=-1;
b[flag]=t+cnt*20;
}
++cnt;
}
gra[1][0]+=a[1];
gra[1][1]+=b[1];
for(auto&&k:{0,2}){
q[k].pb({a[k]-a[1],b[k]-b[1]});
}
}
sort(all(q[0]));
sort(all(q[2]));
gra[0]=gra[2]=gra[1];
gra[0][0]+=q[0].front()[0];
gra[0][1]+=q[0].front()[1];
gra[2][0]+=q[2].back()[0];
gra[2][1]+=q[2].back()[1];
return gra;
};
V<V<std::array<int,2>>> gra(3);
for(int c=0;c<N;++c){
// for(int i=1;i<=26;++i)sub[i].eb(300,0);
auto&&res=calc(c);
for(int k:{0,1,2}){
gra[k].eb(res[k]);
}
}
int n=count_if(all(gra[1]),[](auto x){return x[0];});
int thr=std::min<int>((n+9)/10,35),thr2=thr;
if(n!=id.size()){
thr2=std::min<int>((n+1+9)/10,35);
}
vi p(N),ans(N);
debug(N,thr,gra);
if(thr==0){
for(auto&&x:ans)x=1;
}else{
iota(all(p),0);
auto add=[&](){
std::ranges::sort(all(p),{},[&](int i){return gra[1][i];});
for(int c=0;c<N;++c){
if(gra[1][c]<=gra[1][p[thr-1]]){
ans[c]=1;
}
}
};
add();
std::array<int,2>dn={-33,0};
int can0=0,Au=0,pos=-1;
for(int c=0;c<N;++c){
if(gra[1][c]<=gra[1][p[thr-1]]){
// ++Au;
if(gra[2][c][0]&&ckmax(dn,gra[2][c]))pos=c;
else can0=c;
}
// if(gra[1][c]<=gra[1][p[thr2-1]]){
// ans[c]=1;
// }
if(gra[0][c]<=gra[1][p[(gra[1][c][0]?thr:thr2)-1]]){
ans[c]=1;
}
}
int thr3=std::min<int>((n-1+9)/10,35);
debug(thr,thr2,thr3);
if(thr3==thr&&~can0){
pos=can0;
}
if(~pos){
auto bak=gra[1][pos];
gra[1][pos]=gra[2][pos];
add();
gra[1][pos]=bak;
}
debug(dn);
for(auto&&[bel,p,t,s]:subl|all::R){
if(!gra[1][bel][0]){
gra[1][bel][0]=-1,gra[1][bel][1]=t;
thr=thr2;
add();
thr=std::min<int>((n+9)/10,35);
gra[1][bel]={0,0};
break;
}
}
// if(Au==thr)for(int c=0;c<N;++c)if(gra[1][c]<=dn){
// ans[c]=1;
// }
}
printf("%zu\n",count(all(ans),1));
for(int i=0;i<N;++i)if(ans[i])printf("%s ",name[i].c_str());
puts("");
}();
}//main()
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4076kb
input:
2 5 TSxingxing10 G 0 rejected TSxingxing10 B 83 accepted aoliaoligeiliao J 98 accepted TS1 J 118 accepted TS1 B 263 accepted 12 AllWayTheNorth A 0 rejected YaoYaoLingXian Y 10 accepted XuejunXinyoudui1 X 200 rejected XuejunXinyoudui1 X 200 accepted LetItRot L 215 accepted AllWayTheNorth W 250 accept...
output:
2 TSxingxing10 TS1 4 AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan
result:
ok 2 test cases ok. (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 4088kb
input:
2 2 jiangly_fan A 1 accepted jiangly B 23 accepted 3 conqueror_of_tourist A 1 accepted conqueror_of_tourist A 2 accepted tourist B 23 accepted
output:
2 jiangly_fan jiangly 1 conqueror_of_tourist
result:
ok 2 test cases ok. (2 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2 13 A A 1 accepted A X 1 accepted K K 1 rejected B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 accepted H H 2 accepted I I 2 accepted J J 2 accepted K K 2 rejected 12 A A 1 accepted A X 1 accepted B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 a...
output:
11 A K B C D E F G H I J 1 A
result:
ok 2 test cases ok. (2 test cases)
Test #4:
score: 0
Accepted
time: 0ms
memory: 4072kb
input:
2 11 A A 1 accepted B B 1 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 accepted H H 2 accepted I I 2 accepted J J 2 accepted K K 2 accepted 12 A A 1 accepted A X 1 accepted K K 1 rejected B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 a...
output:
2 A B 2 A K
result:
ok 2 test cases ok. (2 test cases)
Test #5:
score: 0
Accepted
time: 71ms
memory: 3816kb
input:
100000 1 M3JytWoaEXxkACy_mBAQ R 111 accepted 1 sQ O 151 accepted 1 JinbrcS58gNEE5yTSkT B 140 accepted 1 cklwBY V 243 accepted 1 v_o42YmvEKFwy Q 260 rejected 1 ftQVK8S_um22w K 265 accepted 1 _bQBeFeDpYQhvZcLf9l3 Z 147 accepted 1 KvDcEAIDN A 75 rejected 1 H3MUK6 A 101 rejected 1 gxYo_oCFn2J8aIben U 54...
output:
1 M3JytWoaEXxkACy_mBAQ 1 sQ 1 JinbrcS58gNEE5yTSkT 1 cklwBY 1 v_o42YmvEKFwy 1 ftQVK8S_um22w 1 _bQBeFeDpYQhvZcLf9l3 1 KvDcEAIDN 1 H3MUK6 1 gxYo_oCFn2J8aIben 1 _isnlUGK0ddI 1 BERcVjyCp 1 6In2do_50ylch 1 f0r3SXc6brMjT 1 7njYOapSwvogA 1 x 1 y1w3KvxylfxwprRBYw 1 aGedzS 1 iPo0GDhIF 1 4Vf...
result:
ok 100000 test cases ok. (100000 test cases)
Test #6:
score: -100
Wrong Answer
time: 61ms
memory: 3988kb
input:
10000 42 Bzs0PiQMXGZ5rRZ_2D G 2 accepted 9XtB_VIfbRRL E 11 accepted FVJL M 13 rejected a S 19 accepted tsd Z 20 rejected MyCqVEg1ONjZ U 22 accepted 6SgZMn N 51 rejected Qua1Pti3vKhyQKDUm P 54 accepted i29 M 63 accepted zPqu D 68 rejected xx2yiu6x C 71 rejected fYuK1KNkuyO5HRCq L 76 rejected tXWpYVqj...
output:
3 tsd Qua1Pti3vKhyQKDUm fYuK1KNkuyO5HRCq 2 t3 JP 2 fhYPGC8W82NwJTQL 77sgqpbTIr_Zt1 2 pVWDEz 3BQ 2 tg buCeoOotAkV8DaFD6 1 UkXQ3iaNJ 1 vwfw 1 QTEzV6tp 3 4e1l0pO8eFjZwkDo wJlbqIU 9cy_y_RNRwex8j7224hz 2 eiuF7a_ 6mbCu5zA 1 xy6QBr8ECi 3 ldaKLZb1oS1sS _Yej1PrINtydmOudwoO PezeyUurYoz7N1iGU 4 idq...
result:
wrong answer the numbers are different in the case 1. (test case 1)