QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#243195 | #6723. Grid with Arrows | gzzz# | WA | 52ms | 10168kb | C++20 | 1.2kb | 2023-11-07 21:57:22 | 2023-11-07 21:57:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
string mp[maxn];
vector<vector<int> > s;
int in[maxn],out[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;cin>>t;
while(t--) {
int n,m;
cin>>n>>m;
s.clear();
for(int i=0;i<n;i++){
mp[i].clear();
cin>>mp[i];
}
for(int i=1;i<=n;i++){
vector<int> tmp;
for(int j=1;j<=m;j++){
int x;cin>>x;
tmp.push_back(x);
}
s.push_back(tmp);
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
int fr=i*m+j;
int tox=i,toy=j;
if(mp[i][j]=='r') {
toy+=s[i][j];
}
else if(mp[i][j]=='l'){
toy-=s[i][j];
}
else if(mp[i][j]=='u'){
tox-=s[i][j];
}
else {
tox+=s[i][j];
}
if(tox<0||tox>=n||toy<0||toy>=m) {
continue;
}
else {
int to=tox*m+toy;
in[to]++;
out[fr]++;
}
}
}
int num1=0,num2=0;
for(int i=0;i<=(n-1)*m+(m-1);i++){
if(in[i]>out[i]) {
num1++;
}
else if(out[i]>in[i]){
num2++;
}
}
if(num1!=num2){
cout<<"No\n";
}
else {
if(num1==1||num1==0) {
cout<<"Yes\n";
}
else {
cout<<"No\n";
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6864kb
input:
2 2 3 rdd url 2 1 1 1 1 2 2 2 rr rr 1 1 1 1
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #2:
score: -100
Wrong Answer
time: 52ms
memory: 10168kb
input:
1109 5 8 rddddldl drruludl rrldrurd urrrlluu uurrulrl 4 4 1 2 4 3 1 6 1 3 5 1 1 1 3 6 2 4 1 1 2 1 1 1 2 3 4 2 4 3 3 3 4 1 1 2 2 5 1 5 7 9 rdrddrdll urrdruldl ruullrulu drrlrlddl rrrdddlll ruulururl ruurrlluu 7 1 1 1 2 1 2 3 6 1 7 3 1 3 1 2 1 8 2 2 1 2 4 3 1 2 2 2 2 4 1 1 5 3 3 1 3 4 6 1 2 1 2 7 7 6 ...
output:
Yes Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No N...
result:
wrong answer expected NO, found YES [2nd token]