QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#477646 | #5416. Fabulous Fungus Frenzy | zhao_daodao | Compile Error | / | / | C++14 | 4.5kb | 2024-07-14 08:08:32 | 2024-07-14 08:08:33 |
Judging History
answer
#include<bits/stdc++.h>
#define Pair pair<int,int>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);i++)
#define dF(i,a,b) for(int i=a;i>=(b);i--)
const string C="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@";
unordered_map<int,int>mp;
const int MAXN=20+5;
int n,m,k,sum_;
char Now[MAXN][MAXN];
int sx[MAXN],sy[MAXN];char Z[MAXN][MAXN][MAXN];
int tim[70];//@ 通配符
// 当前匹配 Pair{需要,增加多少 @}
inline Pair need(int u){
int now[70];memset(now,0,sizeof now);
F(i,1,sx[u])F(j,1,sy[u])now[mp[Z[u][i][j]]]++;
int ans=0;
F(i,0,C.size()-2)ans+=max(0,now[i]-tim[i]);
return Pair{ans,sx[u]*sy[u]-ans};
}
struct node{int opt;Pair pl;};
vector<node>ans;
//位移
inline void Move(Pair fir,Pair sec){
if(fir.first==sec.first){
if(fir.second+1==sec.second)
ans.push_back(node{-1,fir});
else ans.push_back(node{-2,fir});
}
else{
if(fir.first+1==sec.first)
ans.push_back(node{-3,fir});
else ans.push_back(node{-4,fir});
}
swap(Now[fir.first][fir.second],Now[sec.first][sec.second]);
}
//盖章
inline void change(int u){
F(i,1,sx[u])F(j,1,sy[u]){
bool flag=0;
if(Now[i][j]==Z[u][i][j]){
flag=1,place=Pair{i,j};
}
for(int x=1;x<=n&&!flag;x++){
for(int y=1;y<=m&&!flag;y++)
if((x>i)||(x==i&&y>=j)||(x<i&&y>sy[u])){
if(Now[x][y]==Z[u][i][j]){
flag=1,place=Pair{x,y};
}
}
}
if(!flag){
if(Now[i][j]=='@'){
flag=1;place=Pair{i,j};
}
for(int x=1;x<=n&&!flag;x++){
for(int y=1;y<=m&&!flag;y++)
if((x>i)||(x==i&&y>=j)||(x<i&&y>sy[u])){
if(Now[x][y]=='@'){
flag=1;place=Pair{x,y};
}
}
}
}
// cerr<<i<<" "<<j<<" "<<place.first<<" "<<place.second<<"\n";
if(place.first<=i){
while(place.first<i){
Pair ano=Pair{place.first+1,place.second};
Move(place,ano);place=ano;
}
while(place.second<j){
Pair ano=Pair{place.first,place.second+1};
Move(place,ano);place=ano;
}
while(place.second>j){
Pair ano=Pair{place.first,place.second-1};
Move(place,ano);place=ano;
}
}
else{
while(place.second<j){
Pair ano=Pair{place.first,place.second+1};
Move(place,ano);place=ano;
}
while(place.second>j){
Pair ano=Pair{place.first,place.second-1};
Move(place,ano);place=ano;
}
while(place.first>i){
Pair ano=Pair{place.first-1,place.second};
Move(place,ano);place=ano;
}
}
}
F(i,1,sx[u])F(j,1,sy[u])Now[i][j]='@';
memset(tim,0,sizeof tim);
F(i,1,n)F(j,1,m)tim[mp[Now[i][j]]]++;
ans.push_back(node{u,Pair{1,1}});
// F(i,1,n){F(j,1,m)cerr<<Now[i][j];cerr<<"\n";}cerr<<"\n";
}
inline void tiaoshi(){
cout<<n<<" "<<m<<" "<<k<<"\n";
F(i,1,n){F(j,1,m)cout<<Z[k+1][i][j];cout<<"\n";}
F(i,1,n){F(j,1,m)cout<<Now[i][j];cout<<"\n";}
F(_,1,k){
cout<<sx[_]<<" "<<sy[_]<<"\n";
F(i,1,sx[_]){F(j,1,sy[_])cout<<Z[_][i][j];cout<<"\n";}
}
}
signed main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin>>n>>m>>k;
sx[k+1]=n,sy[k+1]=m;
F(i,1,n)F(j,1,m)cin>>Z[k+1][i][j];
F(i,1,n)F(j,1,m)cin>>Now[i][j];
F(i,0,C.size()-1)mp[C[i]]=i;
F(_,1,k){
cin>>sx[_]>>sy[_];
F(i,1,sx[_])F(j,1,sy[_])cin>>Z[_][i][j];
}
// tiaoshi();
F(i,1,n)F(j,1,m)tim[mp[Now[i][j]]]++;
while(1){
int maxx=-1,cnt=-1;
F(i,1,k){
Pair now=need(i);
if(now.first<=tim[mp['@']]&&now.second>maxx){
maxx=now.second;cnt=i;
}
}
if(maxx<=0)break;
change(cnt);
}
Pair now=need(k+1);
if(now.first>tim[mp['@']]){
cout<<"-1";
return 0;
}
change(k+1);
ans.pop_back();
cout<<ans.size()<<"\n";
for(int i=(int)ans.size()-1;i>=0;i--){
cout<<ans[i].opt<<" "<<ans[i].pl.first<<" "<<ans[i].pl.second<<"\n";
}
}
Details
answer.code: In function ‘void change(int)’: answer.code:42:20: error: ‘place’ was not declared in this scope 42 | flag=1,place=Pair{i,j}; | ^~~~~ answer.code:48:28: error: ‘place’ was not declared in this scope 48 | flag=1,place=Pair{x,y}; | ^~~~~ answer.code:54:24: error: ‘place’ was not declared in this scope 54 | flag=1;place=Pair{i,j}; | ^~~~~ answer.code:60:32: error: ‘place’ was not declared in this scope 60 | flag=1;place=Pair{x,y}; | ^~~~~ answer.code:66:12: error: ‘place’ was not declared in this scope 66 | if(place.first<=i){ | ^~~~~ answer.code:68:57: error: no matching function for call to ‘std::pair<int, int>::pair(<brace-enclosed initializer list>)’ 68 | Pair ano=Pair{place.first+1,place.second}; | ^ In file included from /usr/include/c++/13/bits/stl_algobase.h:64, 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_pair.h:719:28: note: candidate: ‘template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]’ 719 | explicit constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/13/bits/stl_pair.h:719:28: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_pair.h:708:19: note: candidate: ‘template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]’ 708 | constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/13/bits/stl_pair.h:708:19: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_pair.h:697:28: note: candidate: ‘template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]’ 697 | explicit constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/13/bits/stl_pair.h:697:28: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_pair.h:687:19: note: candidate: ‘template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]’ 687 | constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/13/bits/stl_pair.h:687:19: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/stl_pair.h:675:9: note: candidate: ‘template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<int, _U1>, std::__not...