QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#290335 | #7733. Cool, It’s Yesterday Four Times More | bachbeo2007 | WA | 1ms | 7708kb | C++23 | 2.8kb | 2023-12-24 20:56:16 | 2023-12-24 20:56:17 |
Judging History
answer
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
#define mpp make_pair
#define fi first
#define se second
const int inf=1e18;
const int mod=998244353;
const int maxn=1005;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000;
const int root=3;
int power(int a,int n){
int res=1;
while(n){
if(n&1) res=res*a%mod;
a=a*a%mod;n>>=1;
}
return res;
}
const int iroot=power(3,mod-2);
const int base=131;
int n,m;
bitset<maxn> bs[2*maxn][2*maxn];
char c[maxn][maxn];
bitset<maxn> cur;
bool vis[maxn][maxn];
int dx[]={0,0,1,-1},
dy[]={1,-1,0,0};
void dfs(int x,int y,int i,int j){
vis[x][y]=true;
int a=maxa+x-i,b=maxa+y-j;
cur|=bs[a][b];
for(int t=0;t<4;t++){
int xt=x+dx[t],yt=y+dy[t];
if(xt<0 || yt<0 || xt>=n || yt>=m || c[xt][yt]=='O' || vis[xt][yt]) continue;
dfs(xt,yt,i,j);
}
}
void solve(){
cin >> n >> m;
for(int i=maxa-n;i<=maxa+n;i++) for(int j=maxa-m;j<=maxa+m;j++) bs[i][j].reset();
for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> c[i][j];
int res=0;
for(int i=0;i<n;i++) for(int j=0;j<m;j++){
for(int p=-i-1;p<=n-i;p++) for(int q=-j-1;q<=m-j;q++){
int x=i+p,y=j+q;
if(x<0 || y<0 || x>=n || y>=m || c[x][y]=='O') bs[maxa+p][maxa+q].set(i*m+j);
}
}
for(int i=0;i<n;i++) for(int j=0;j<m;j++){
for(int p=0;p<n;p++) for(int q=0;q<m;q++) vis[p][q]=false;
cur.reset();
dfs(i,j,i,j);
if(cur.count()==n*m-1) res++;
}
cout << res << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int test=1;cin >> test;
while(test--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7696kb
input:
4 2 5 .OO.. O..O. 1 3 O.O 1 3 .O. 2 3 OOO OOO
output:
3 1 0 0
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7708kb
input:
200 2 4 OOO. OO.. 2 3 OOO .O. 3 3 O.O OOO OO. 4 1 . . O O 1 2 .O 1 1 . 2 5 .OO.. .O.O. 2 1 O O 1 1 O 1 3 .OO 5 1 O O . O . 5 2 O. .. O. .O .. 5 3 ... ... .OO ..O OOO 3 5 ..O.O .O.O. .OO.O 5 2 .O OO O. O. .. 2 1 O O 3 5 .O.OO O...O ..OO. 1 5 ..... 5 1 O . O . . 5 3 OOO OO. .OO OO. O.O 2 1 O . 5 2 O. ...
output:
3 0 0 2 1 1 3 0 0 2 0 7 9 4 5 0 6 5 3 0 1 6 4 6 2 0 0 5 3 3 1 4 2 0 7 5 2 3 7 3 0 6 3 2 3 0 4 6 6 4 3 3 5 5 2 1 0 5 3 4 4 2 3 0 7 6 4 8 5 5 2 5 2 1 2 1 4 0 0 2 5 1 4 6 8 1 7 2 2 3 7 5 2 3 0 4 9 4 5 11 0 3 2 1 0 0 4 3 1 4 3 8 4 0 5 6 2 7 2 3 6 4 0 2 11 2 3 4 0 4 4 6 2 3 2 3 0 5 0 16 5 3 2 6 0 8 3 3 1...
result:
wrong answer 10th lines differ - expected: '1', found: '2'