QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#252433 | #4434. Lemurs | oogerbooger# | WA | 46ms | 3804kb | C++14 | 3.5kb | 2023-11-15 19:32:18 | 2023-11-15 19:32:19 |
Judging History
answer
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define INF 1e9
#define INFl 1e18
#define all(x) x.begin(), x.end()
#define sajz(x) (int)x.size()
#define pb push_back
#define se second
#define fi first
#define yes puts("YES")
#define no puts("NO")
#define erase_duplicates(x) {sort(all(x));(x).resize(distance((x).begin(), unique(all(x))));}
using namespace std;
//using namespace __gnu_pbds;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef multiset<int> msi;
typedef long double ld;
//typedef cc_hash_table<int, int, hash<int>> ht;
int n, m;
vector<pii> moves{{0,1},{0,-1},{1,0},{-1,0}};
vector<pii> neigh(pii cur) {
vector<pii> res;
for(auto p : moves) {
int row = p.fi+cur.fi, col = p.se+cur.se;
if(0 <= row && row < n && 0 <= col && col < m) res.pb({row,col});
}
return res;
}
void test_case() {
int k;
cin >> n >> m >> k;
vector<vector<int>> dist(n, vector<int>(m, 0));
vector<vector<bool>> vis(n, vector<bool>(m, 0));
vector<vector<char>> tab(n, vector<char>(m));
queue<pii> q;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cin >> tab[i][j];
if(tab[i][j] == '.') {
vis[i][j] = 1;
q.push({i,j});
}
}
}
if(q.empty()) {
cout << "TAK\n";
return;
}
while(!q.empty()) {
pii cur = q.front();
q.pop();
for(auto cur2 : neigh(cur)) {
if(!vis[cur2.fi][cur2.se]) {
dist[cur2.fi][cur2.se] = dist[cur.fi][cur.se]+1;
vis[cur2.fi][cur2.se] = 1;
q.push({cur2.fi,cur2.se});
}
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
vis[i][j] = 0;
if(dist[i][j] > k) {
vis[i][j] = 1;
q.push({i,j});
}
}
}
while(!q.empty()) {
pii cur = q.front();
q.pop();
for(auto cur2 : neigh(cur)) {
if(!vis[cur2.fi][cur2.se] && dist[cur.fi][cur.se] > dist[cur2.fi][cur2.se]) {
vis[cur2.fi][cur2.se] = 1;
q.push({cur2.fi,cur2.se});
}
}
}
bool ans = true;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(tab[i][j] == 'x' && !vis[i][j]) ans = false;
}
}
cout << (ans?"TAK\n":"NIE\n");
}
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int tc = 1;
cin >> tc;
while(tc--) {
test_case();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 46ms
memory: 3804kb
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 TAK NIE NIE TAK NIE TAK NIE NIE TAK TAK NIE TAK TAK NIE NIE NIE NIE NIE NIE NIE NIE NIE TAK NIE NIE TAK TAK TAK NIE NIE NIE TAK TAK NIE NIE TAK NIE NIE NIE TAK NIE NIE NIE TAK NIE NIE NIE NIE TAK 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 406th lines differ - expected: 'TAK', found: 'NIE'