QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454879 | #8230. Submissions | ZSH_ZSH | Compile Error | / | / | C++14 | 4.2kb | 2024-06-25 16:03:05 | 2024-06-25 16:03:05 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define drep(i,a,b) for (int i=(a);i>=(b);i--)
using namespace std;
typedef long long ll;
#define fir first
#define sec second
typedef pair<int,int> pii;
inline pii operator + (const pii &x,const pii &y){return {x.fir+y.fir,x.sec+y.sec};}
inline pii operator - (const pii &x,const pii &y){return {x.fir-y.fir,x.sec-y.sec};}
struct sub
{
int id,prob,t,status;
};
inline pii better(const pii &x,const pii &y)
{
if (x.fir<y.fir) return y;
if (x.fir>y.fir) return x;
return {x.fir,min(x.sec,y.sec)};
}
void solve()
{
int m; cin>>m;
int n=0;
map<string,int> teamid;
vector<string> names;
vector<array<vector<sub>,26> > V;
rep(i,1,m)
{
string name;
char prob;
int t;
string status;
cin>>name>>prob>>t>>status;
if (!teamid.count(name))
{
teamid[name]=n++;
V.push_back({});
names.push_back(name);
}
int id=teamid[name];
int p=prob-'A';
int s=(status[0]=='a')?1:0;
V[id][p].push_back((sub){id,p,t,s});
}
assert(V.size()==n);
auto getord=[&](const vector<pii> &score)
{
vector<int> ord(n);
rep(i,0,n-1) ord[i]=i;
sort(ord.begin(),ord.end(),[&](auto i,auto j)
{
auto x=score[i];
auto y=score[j];
if (better(x,y)!=y) return 1;
return 0;
});
return ord;
};
auto sim=[&](const vector<sub> &v) -> pii
{
pii now={0,0};
int wa=0;
for (auto it:v)
{
if (it.status==1)
{
return {1,it.t+wa*20};
}
else wa++;
}
return now;
};
vector<int> canwin(n);
auto simulate=[&]()
{
vector<pii> score(n);
rep(id,0,n-1)
{
rep(p,0,25)
{
score[id]=score[id]+sim(V[id][p]);
}
}
int valid=0;
rep(i,0,n-1) if (score[i].fir) valid++;
vector<int> ord=getord(score);
if (valid!=0)
{
int gold=min(35,(valid+9)/10);
rep(i,0,gold-1) canwin[ord[i]]=1;
int j=gold-1;
while (j+1<n&&score[ord[gold-1]]==score[ord[j+1]]) j++;
rep(i,gold,j) canwin[ord[i]]=1;
}
else rep(i,0,n-1) canwin[i]=1;
return score;
};
auto score=simulate();
auto ord=getord(score);
rep(ii,0,min(n-1,35))
{
int id=ord[ii];
pii best={0,0};
pii pos={-1,-1};
rep(p,0,25)
{
int f=-1;
rep(i,0,(int)V[id][p].size()-1) if (V[id][p][i].status==1)
{
f=i;
break;
}
if (f==-1) continue;
auto now=sim(V[id][p]);
V[id][p][f].status=0;
auto nxt=sim(V[id][p]);
V[id][p][f].status=1;
auto diff=now-nxt;
if (diff==better(best,diff))
{
pos={p,f};
best=diff;
}
}
if (pos.fir!=-1)
{
V[id][pos.fir][pos.sec].status=0;
simulate();
V[id][pos.fir][pos.sec].status=1;
}
}
int valid=0;
rep(i,0,n-1) if (score[i].fir) valid++;
int luckyt=-1;
array<int,3> lucky={-1,-1,-1};
rep(id,0,n-1)
{
pii best={0,0};
rep(p,0,25)
{
int f=-1;
rep(i,0,(int)V[id][p].size()-1) if (V[id][p][i].status==0)
{
f=i;
break;
}
if (f==-1) continue;
auto now=sim(V[id][p]);
V[id][p][f].status=1;
auto nxt=sim(V[id][p]);
V[id][p][f].status=0;
auto diff=nxt-now;
if (diff==better(best,diff))
{
best=diff;
}
}
auto ns=score[id]+best;
int nv=(valid-(score[id].fir>0)+(ns.fir>0));
if (nv)
{
int gold=min(35,(nv+9)/10);
auto g=score[ord[gold-1]];
if (better(score[ord[gold-1]],ns)==ns)
{
canwin[id]=1;
}
}
if (score[id].fir==0&&ns.fir!=0)
{
int t=-1;
pii pos={-1,-1};
rep(p,0,25)
{
int f=-1;
int wa=0;
rep(i,0,(int)V[id][p].size()-1)
{
int tt=V[id][p][i]+wa*20;
if (t<tt)
{
t=tt;
pos={p,i};
}
wa++;
}
}
if (t>luckyt)
{
luckyt=t;
lucky={id,pos.fir,pos.sec};
}
}
}
if (lucky[0]!=-1)
{
V[lucky[0]][lucky[1]][lucky[2]].status=1;
simulate();
V[lucky[0]][lucky[1]][lucky[2]].status=0;
}
vector<string> winner;
rep(i,0,n-1) if (canwin[i]) winner.push_back(names[i]);
printf("%d\n",winner.size());
for (auto x:winner) printf("%s ",x.c_str());
printf("\n");
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T; cin>>T;
while (T--) solve();
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:196:59: error: no match for ‘operator+’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<sub>, sub>::value_type’ {aka ‘sub’} and ‘int’) 196 | int tt=V[id][p][i]+wa*20; In file included from /usr/include/c++/13/bits/stl_algobase.h:67, from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_iterator.h:634:5: note: candidate: ‘template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)’ 634 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:634:5: note: template argument deduction/substitution failed: answer.code:196:63: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘int’ 196 | int tt=V[id][p][i]+wa*20; | ^~ /usr/include/c++/13/bits/stl_iterator.h:1808:5: note: candidate: ‘template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)’ 1808 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1808:5: note: template argument deduction/substitution failed: answer.code:196:63: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘int’ 196 | int tt=V[id][p][i]+wa*20; | ^~ In file included from /usr/include/c++/13/string:54, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52: /usr/include/c++/13/bits/basic_string.h:3541:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3541 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3541:5: note: template argument deduction/substitution failed: answer.code:196:63: note: ‘__gnu_cxx::__alloc_traits<std::allocator<sub>, sub>::value_type’ {aka ‘sub’} is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 196 | int tt=V[id][p][i]+wa*20; | ^~ /usr/include/c++/13/bits/basic_string.h:3559:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3559 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3559:5: note: template argument deduction/substitution failed: answer.code:196:63: note: mismatched types ‘const _CharT*’ and ‘sub’ 196 | int tt=V[id][p][i]+wa*20; | ^~ /usr/include/c++/13/bits/basic_string.h:3578:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3578 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3578:5: note: template argument deduction/substitution failed: answer.code:196:63: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ 196 | int tt=V[id][p][i]+wa*20; | ^~ /usr/include/c++/13/bits/basic_string.h:3595:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 3595 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3595:5: note: template argument deduction/substitution failed: answer.code:196:63: note: ‘__gnu_cxx::__alloc_traits<std::allocator<sub>, sub>::value_type’ {aka ‘sub’} is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 196 | int tt=V[id][p][i]+wa*20; | ...