QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189952 | #4434. Lemurs | berarchegas# | WA | 29ms | 132936kb | C++20 | 4.4kb | 2023-09-28 01:58:51 | 2023-09-28 01:58:52 |
Judging History
answer
#include <bits/stdc++.h>
#include <iostream>
// #define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v)),v.erase(unique(all(v)),v.end());
#define sz(v) ((int)v.size())
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
//#define left oooooopss
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
// std::mt19937_64 rng64((int) std::chrono::steady_clock::now().time_since_epoch().count());
std::mt19937 rng(
// (int) std::chrono::steady_clock::now().time_since_epoch().count()
1239010
);
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
//inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll b,ll e,ll m){
b%=m;
ll ans = 1;
for (; e; b = b * b % m, e /= 2)
if (e & 1) ans = ans * b % m;
return ans;
}
// debug:
template<class T>void print_vector(vector<T> &v){
rep(i,0,sz(v))cout<<v[i]<<" \n"[i==sz(v)-1];
}
void dbg_out() {cerr << endl; }
template<typename Head, typename ... Tail> void dbg_out(Head H,Tail... T){
cerr << ' ' << H;
dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__), cerr << endl
#else
#define dbg(...) 42
#endif
//
const int N = 5050;
const int SHIFT = 1010;
char mat[N][N];
pii rot[N][N];
int pre[N][N];
int pre2[N][N];
void solve(){
int n,m,k;
cin >> n >> m >> k;
rep(a,1,2*(n+m) + 1){
rep(b,1,2*(n+m) + 1){
pre[a][b] = 0;
pre2[a][b] = 0;
}
}
rep(i,1,n+1){
rep(j,1,m+1){
cin >> mat[i][j];
rot[i][j] = pii(1 + i+j,1 + i-j+n);
if(mat[i][j] == '.'){
pre[rot[i][j].ff][rot[i][j].ss]++;
}
}
}
rep(a,1,2*(n+m)){
rep(b,1,2*(n+m)){
pre[a][b] += pre[a-1][b] + pre[a][b-1] - pre[a-1][b-1];
}
}
auto getSum = [&](int li,int lj, int ri,int rj){
li = max(li,1),lj = max(lj,1);
ri = min(ri,2*(n+m));
rj = min(rj,2*(n+m));
return pre[ri][rj] - pre[ri][lj-1] - pre[li-1][rj] + pre[li-1][lj-1];
};
auto Soma = [&](int li,int lj,int ri,int rj){
li = max(li,1),lj = max(lj,1);
ri = min(ri,2*(n+m));
rj = min(rj,2*(n+m));
pre2[li][lj]++;
pre2[li][rj+1]--;
pre2[ri+1][lj]--;
pre2[ri+1][rj+1]++;
};
rep(i,1,n+1){
rep(j,1,m+1){
if(mat[i][j] == 'x'){
int tot = getSum(
rot[i][j].ff - k, rot[i][j].ss - k,
rot[i][j].ff + k, rot[i][j].ss + k
);
if(tot == 0){
// pode ser
// pre2[rot[i][j].ff][rot[i][j].ss]++;
// dbg("pinta",i,j);
Soma(rot[i][j].ff - k, rot[i][j].ss - k,
rot[i][j].ff + k, rot[i][j].ss + k);
}
}
}
}
rep(a,1,2*(n+m)){
rep(b,1,2*(n+m)){
pre2[a][b] += pre2[a-1][b] + pre2[a][b-1] - pre2[a-1][b-1];
}
}
rep(i,1,n+1){
rep(j,1,m+1){
if(mat[i][j] == 'x'){
if(pre2[rot[i][j].ff][rot[i][j].ss] == 0){
// dbg(" bad ",i,j);
cout << "NIE" << endl;
return;
}
}
}
}
cout << "TAK" << endl;
}
int32_t main(){
fastio;
int t;
cin >> t;
while(t--){
solve();
}
// math -> gcd it all
// Did you swap N,M? N=1?
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 29ms
memory: 132936kb
input:
4000 1 1 1 . 1 1 1 x 1 1 1000 . 1 1 1000 x 1 1000 4 ..........................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx....xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
TAK TAK TAK TAK NIE NIE NIE TAK NIE TAK NIE NIE TAK TAK NIE TAK TAK NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE TAK TAK NIE NIE NIE NIE TAK TAK NIE NIE NIE NIE NIE NIE TAK NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE NIE TAK NIE NIE NIE TAK TAK ...
result:
wrong answer 5th lines differ - expected: 'TAK', found: 'NIE'