QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#465984#7733. Cool, It’s Yesterday Four Times Moreevirir#WA 3ms3788kbC++142.3kb2024-07-07 14:28:312024-07-07 14:28:31

Judging History

你现在查看的是最新测评结果

  • [2024-07-07 14:28:31]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3788kb
  • [2024-07-07 14:28:31]
  • 提交

answer

#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
using cd = complex<ld>;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
bitset<2000>a[1000];
string g[1000];
bool vis[2000];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int n,m;
void get(int i,int j){
    queue<pii>q;
    q.push({i,j});
    for(int k=0;k<2000;k++){
        a[i*m+j][k] = 0;
        vis[k] = 0;
    }
    vis[i*m+j] = 1;
    while(!q.empty()){
        int x = q.front().fi;
        int y = q.front().se;
        q.pop();
        int idx = (i-x)*m + (y-j);
        idx += 1000;
        a[i*m+j][idx] = 1;
        for(int k=0;k<4;k++){
            int xn = x+dx[k];
            int yn = y+dy[k];
            if(xn>=0 && xn<n && yn>=0 && yn<m && g[xn][yn] == '.' && !vis[xn*m+yn]){
                q.push({xn,yn});
                vis[xn*m+yn] = 1;
            }
        } 

    }
}
int main()
{
    owo
    int t;
    cin>>t;
    while(t--){
        cin>>n>>m;
        vector<int>in(n*m,1);
        for(int i=0;i<n;i++)cin>>g[i];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(g[i][j] == '.')get(i,j);
                else in[i*m+j] = 0;
            }
        }
        for(int i=0;i<n*m;i++){
            if(g[i/m][i%m] == 'O')continue;
            for(int j=i+1;j<n*m;j++){
                if(g[j/m][j%m] == 'O')continue;
                //cout<<i<<" "<<j<<'\n';
                auto res = a[i] & a[j];
                if(res == a[i])in[i] = 0;
                if(res == a[j])in[j] = 0;
            }
        }
        int ans = 0;
        for(int i=0;i<n*m;i++)ans+=in[i];
        cout<<ans<<'\n';
    }



}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

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: 3ms
memory: 3572kb

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
1
0
4
9
4
4
0
6
5
2
0
1
6
4
5
2
0
0
5
3
3
1
4
1
0
7
5
2
3
7
3
0
6
2
2
2
0
4
6
6
3
3
2
3
5
2
1
0
3
3
4
4
2
2
0
7
6
4
8
5
3
2
5
2
1
2
1
4
0
0
2
5
1
4
6
6
1
6
2
2
3
4
5
2
1
0
1
9
3
4
11
0
3
2
1
0
0
4
3
1
4
3
8
3
0
3
6
2
5
1
3
3
4
0
2
11
2
2
4
0
4
4
6
2
1
2
3
0
5
0
16
4
3
2
6
0
8
3
3
1...

result:

wrong answer 12th lines differ - expected: '7', found: '4'