QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402167 | #1076. Flooding Fields | stasio6# | WA | 8ms | 7760kb | C++14 | 1.4kb | 2024-04-30 03:06:46 | 2024-04-30 03:06:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
typedef pair<int, int> pii;
typedef vector<int> vi;
template<class X, class Y> X cmx(X &a, Y b) { a = max<X>(a, b); }
#define ary(k) array<int, k>
int n,k,h,a[200][200],p[1<<20],q[1<<20],f[30][200][200],x,y,A,w[1<<20],X[]={0,-1,0,0,1},Y[]={0,0,-1,1,0};
void Z(){
cin>>n>>k>>h;
if(n==0&&k==0&&h==0)
exit(0);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
cin>>a[i][j];
for(int i=1;i<=k;i++)
cin>>p[i]>>q[i],p[i]++,q[i]++;
for(int i=1;i<=h;i++)
cin>>w[i];
w[0]=-1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
f[h][i][j]=a[i][j]>w[h];
for(int k=h-1;~k;k--)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++){
f[k][i][j]=0;
if(a[i][j]<=w[k])
continue;
for(int l=0;l<5;l++)
f[k][i][j]|=1<=(x=i+X[l])&&x<=n&&1<=(y=j+Y[l])&&y<=n&&f[k+1][x][y];
}
A=0;
for(int i=1;i<=k;i++)
A+=f[0][p[i]][q[i]];
cout<<A<<'\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
while(1)
Z();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 7760kb
input:
3 1 3 2 1 2 3 1 3 2 4 2 1 1 0 2 1 2 4 2 0 1 1 2 0 0 0 1 1 1 1 0 1 0 50 50 24 5 20 21 3 2 9 22 15 19 22 18 14 19 14 15 4 22 22 7 12 7 2 2 0 25 0 7 6 4 3 2 17 1 12 7 12 1 19 12 3 23 5 5 10 22 15 17 3 13 4 10 21 7 12 10 22 23 18 17 5 17 18 2 14 12 13 13 19 19 18 8 11 3 0 24 0 6 1 9 12 14 13 20 22 5 13 ...
output:
1 3 2 2 2 2 0 93 99 72
result:
wrong answer 2nd lines differ - expected: '1', found: '3'