QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783250#6259. Gluttonous Goop353cerega#WA 2ms10180kbC++142.2kb2024-11-26 03:15:102024-11-26 03:15:11

Judging History

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

  • [2024-11-26 03:15:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10180kb
  • [2024-11-26 03:15:10]
  • 提交

answer

//#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define X first
#define Y second


const ll mod = 1000000007;
//const ll mod = 998244353;



ll pew(ll a, ll b) {
    ll res = 1;
    while (b>0) {
        if (b&1) res = res*a%mod;
        b >>= 1;
        a = a*a%mod;
    }
    return res;
}


const ll N = 200353;
ll A[N], mx[N], h[N];
vector<ll> g[N];

void dfs(int u) {
    mx[u] = h[u];
    if (g[u].size()==0) return;
    for (int v: g[u]) {
        h[v] = h[u]+1;
        dfs(v);
        if (mx[u]==h[u]) {
            mx[u] = mx[v];
            continue;
        }
        if (mx[u]<mx[v]) {
            swap(mx[u],mx[v]);
        }
        A[mx[v]-h[u]]++;
    }
}



void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<string> s(n);
    for (ll i=0;i<n;i++) cin >> s[i];
    vector<pair<ll,ll>> a;
    vector<pair<ll,ll>> ord;
    for (ll i=0;i<n;i++) {
        for (ll j=0;j<n;j++) {
            if (s[i][j]!='#') continue;
            ord.push_back({i-k,a.size()});
            ord.push_back({i+k+1,a.size()});
            a.push_back({j-k,j+k+1});
        }
    }
    sort(ord.begin(),ord.end());
    n = a.size();
    vector<ll> cur(n);
    ll ans = 0;
    for (ll w=0;w<ord.size();) {
        ll T = ord[w].X;
        while (w<ord.size() and ord[w].X==T) {
            cur[ord[w].Y] ^= 1;
            w++;
        }
        if (w==ord.size()) break;
        ll D = ord[w].X-T;
        vector<pair<ll,ll>> q;
        for (ll i=0;i<n;i++) {
            if (cur[i]==0) continue;
            q.push_back({a[i].X,1});
            q.push_back({a[i].Y,-1});
        }
        sort(q.begin(),q.end());
        ll Q = 0;
        for (ll w=0;w<q.size();w++) {
            Q += q[w].Y;
            if (Q>0) ans += D*(q[w+1].X-q[w].X);
        }
    }
    cout << ans << "\n";

}

int main() {
    ios_base::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9568kb

input:

5 5 3
.....
.###.
.#.#.
.###.
.....

output:

81

result:

ok single line: '81'

Test #2:

score: 0
Accepted
time: 2ms
memory: 10032kb

input:

3 3 1
#..
.#.
..#

output:

19

result:

ok single line: '19'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 10180kb

input:

4 6 3
..##..
.#..#.
.#..#.
..##..

output:

88

result:

wrong answer 1st lines differ - expected: '96', found: '88'