QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#557108#360. Cultivationmakrav0 0ms3632kbC++202.3kb2024-09-11 03:20:142024-09-11 03:20:14

Judging History

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

  • [2024-09-11 03:20:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3632kb
  • [2024-09-11 03:20:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

void solve() {
    int h, w, n; cin >> h >> w >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {cin >> a[i].first >> a[i].second; a[i].first--; a[i].second--; }
    int ans = 1e9;
    vector<int> ups, dwns;
    for (int i = 0; i < n; i++) ups.pb(a[i].first);
    sort(all(ups));
    for (int up : ups) {
         if (up>ans)continue;
        for (int down=0;down<h;down++){
            for (int left=0;left<w;left++) {
                if (up+left+down>ans)continue;
                for (int right = 0;right<w;right++) {
                    if (up+left+right+down>ans)continue;
                    vector<vector<int>> us(h+1, vector<int>(w+1));
                    for (int i = 0; i < n; i++) {
                        int I1 = max(0, a[i].first - up), I2 = min(h - 1, a[i].first + down), J1 = max(0, a[i].second - left), J2 = min(w - 1, a[i].second + right);
                        us[I1][J1]++;
                        us[I1][J2 + 1]--;
                        us[I2 + 1][J1]--;
                        us[I2 + 1][J2 + 1]++;
                    }
                    bool good = true;
                    if (!us[0][0]) continue;
                    for (int i = 0; i < n; i++) {
                        if(!good)break;
                        for (int j = 0; j < w; j++) {
                            if (i > 0) us[i][j] += us[i - 1][j];
                            if (j > 0) us[i][j] += us[i][j - 1];
                            if (i>0&&j>0) us[i][j] -= us[i-1][j-1];
                            if (us[i][j]==0) {
                                good=false;break;
                            }
                        }
                    }
                    if(good)ans=min(ans,up+down+left+right);
                }
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL 
        freopen("in.txt", "r", stdin);
        freopen("out1.txt", "w", stdout);

        cin >> tt;
    #else
        ios::sync_with_stdio(false); 
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3516kb

input:

2 4
2
1 1
1 4

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3632kb

input:

4 1
1
2 1

output:

1

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Memory Limit Exceeded

Test #45:

score: 0
Memory Limit Exceeded

input:

1000000000 1000000000
17
822413671 70423910
260075513 431043546
300945721 793553248
142848049 163787897
392462410 831950868
699005697 111397300
444396260 130450496
642691616 595456084
467968916 463598810
159764248 611476406
929313754 539645102
365153650 964108073
906780716 373514044
970118116 655138...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%