QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#785189 | #7733. Cool, It’s Yesterday Four Times More | adivse | WA | 1ms | 3572kb | C++20 | 3.9kb | 2024-11-26 17:05:45 | 2024-11-26 17:05:50 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <iomanip>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename T>
void cc(const vector<T>& tem) { for (const auto& x : tem) cout << x << ' '; cout << endl; }
template<typename T>
void cc(const T& a) { cout << a << endl; }
template<typename T1, typename T2>
void cc(const T1& a, const T2& b) { cout << a << ' ' << b << endl; }
template<typename T1, typename T2, typename T3>
void cc(const T1& a, const T2& b, const T3& c) { cout << a << ' ' << b << ' ' << c << endl; }
void cc(const string& s) { cout << s << endl; }
void fileRead() {
#ifdef LOCALL
freopen("D:\\AADVISE\\cppvscode\\CODE\\in.txt", "r", stdin);
freopen("D:\\AADVISE\\cppvscode\\CODE\\out.txt", "w", stdout);
#endif
}
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline double max(double a, double b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
inline double min(double a, double b) { if (a < b) return a; return b; }
void cmax(int& a, const int& b) { if (b > a) a = b; }
void cmin(int& a, const int& b) { if (b < a) a = b; }
void cmin(double& a, const double& b) { if (b < a) a = b; }
void cmax(double& a, const double& b) { if (b > a) a = b; }
using PII = pair<int, int>;
using i128 = __int128;
using vec_int = std::vector<int>;
using vec_char = std::vector<char>;
using vec_double = std::vector<double>;
using vec_int2 = std::vector<std::vector<int>>;
using que_int = std::queue<int>;
//--------------------------------------------------------------------------------
const int N = 1e3 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;
char A[N][N];
int vis[N][N];
int id;
int Q[5] = { 0,0,1,-1 };
int W[5] = { 1,-1,0,0 };
//--------------------------------------------------------------------------------
//struct or namespace:
//--------------------------------------------------------------------------------
signed main() {
fileRead();
kuaidu();
T = 1;
cin >> T;
while (T--) {
cin >> n >> m;
rep(i, 1, n) rep(j, 1, m) cin >> A[i][j];
rep(i, 1, n) rep(j, 1, m) vis[i][j] = 0;
int ans = 0;
rep(i, 1, n) rep(j, 1, m) {
if (vis[i][j] or A[i][j] == 'O') continue;
vector<PII> path;
queue<PII> F;
F.push({ i,j });
while (!F.empty()) {
auto [x, y] = F.front(); F.pop();
vis[x][y] = ++id;
path.push_back({ x - i,y - j });
for (int k = 0; k <= 3; k++) {
int tx = x + Q[k], ty = y + W[k];
if (tx<1 or ty<1 or tx>n or ty>m) continue;
if (A[tx][ty] == 'O' || vis[tx][ty]) continue;
F.push({ tx,ty });
}
}
// cc(path.size());
rep(x1, 1, n) rep(y1, 1, m) {
if (vis[x1][y1] == vis[i][j]) continue;
if (A[x1][y1] == 'O') continue;
bool flag = 0;
for (auto [dx, dy] : path) {
if (x1 + dx<1 or x1 + dx>n or y1 + dy<1 or y1 + dy>m) {
flag = 1;
break;
}
if (A[x1 + dx][y1 + dy] == 'O') {
flag = 1;
break;
}
}
if (flag == 0) goto Z;
}
ans += path.size();
Z:;
}
cc(ans);
}
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
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: 1ms
memory: 3560kb
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 7 12 4 4 0 6 5 2 0 1 6 4 6 2 0 0 7 3 3 1 4 1 0 7 5 2 3 7 3 0 9 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 12 5 3 2 5 2 1 2 1 4 0 0 2 5 1 4 9 7 1 6 2 2 3 4 5 2 1 0 1 17 3 4 19 0 3 2 1 0 0 4 3 1 4 3 11 3 0 3 6 2 5 1 3 3 4 0 2 16 2 2 4 0 4 4 6 2 1 2 3 0 5 0 27 4 3 2 6 0 8 3...
result:
wrong answer 13th lines differ - expected: '9', found: '12'