Get Your Wish
(https://www.luogu.com.cn/problem/P7262)
一个模拟题
解读一下题目:简单来说就是在现在重力的方向上,如果有水滴和电子元件就GG,否则就OK
这里要注意一点,(卡死我这一点,水滴可能不止一滴。
方法:简单判断是否水滴和电子元件处于重力的方向上就好
Acode
int n,m; cin >> n >> m;
char begin; cin >> begin;
vector<pair<int,int>> pa,oo;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ch; cin >> ch;
if(ch == 'o'){
oo.push_back({i,j});
}
if(ch == 'x')pa.push_back({i,j});
}
}
if(!oo.size() || !pa.size())cout << "OK" << endl;
else{
for (int i = 0; i < oo.size(); i++) {
int x = oo[i].first,y = oo[i].second;
for (int j = 0; j < pa.size(); j++) {
if(begin == 'v'){
if(pa[j].second == y){
if(x < pa[j].first){
cout << "GG" << endl;
exit(0);
}
}
}else if(begin == '^'){
if(pa[j].second == y){
if(x > pa[j].first){
cout << "GG" << endl;
exit(0);
}
}
}else if(begin == '>'){
if(pa[j].first == x){
if(y < pa[j].second){
cout << "GG" << endl;
exit(0);
}
}
}else if(begin == '<'){
if(pa[j].first == x){
if(y > pa[j].second){
cout << "GG" << endl;
exit(0);
}
}
}
}
}
cout << "OK" << endl;
}
标签:oo,ch,cout,int,水滴,pa,match,mistake
From: https://www.cnblogs.com/TFOREVERY/p/17061664.html