QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631539#517. Sequential Yahtzeechuchu#WA 1ms3868kbC++202.9kb2024-10-12 08:33:422024-10-12 08:33:44

Judging History

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

  • [2024-10-12 08:33:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2024-10-12 08:33:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve() {
    int n; cin >> n;
    vector<int> rolls(n); for(auto& x : rolls) cin >> x;
    vector<vector<int>> sorted;
    for (int i= 0; i < n-4; ++i) {
        vector<int> tmp;
        for (int j = i; j < i+5; ++j) tmp.push_back(rolls[j]);
        sort(tmp.begin(), tmp.end());
        // for (auto x : tmp) cerr << x << " ";
        // cerr << endl;
        sorted.push_back(tmp);
    }

    auto score = [&] (int cat, int idx) {
        // cerr << idx << " " <<sorted.size() << endl;
        int sum = accumulate(sorted[idx].begin(), sorted[idx].end(), 0);
        if (cat <= 6) {
            int ct =0;
            for (auto x : sorted[idx]) 
                if (x == cat) ct++;
            return ct * cat;
        }
        if (cat == 7) {
            for (int i = 0; i < 3; ++i) {
                if (sorted[idx][i] == sorted[idx][i+2]) return sum;
            }
            return 0;
        }
        if (cat == 8) {
            for (int i = 0; i < 2; ++i) {
                if (sorted[idx][i] == sorted[idx][i+3]) return sum;
            }
            return 0;
        }
        if (cat == 9) {
            if (sorted[idx][0] == sorted[idx][2] && sorted[idx][2] != sorted[idx][3] && sorted[idx][3] == sorted[idx][4]) return 25;
            if (sorted[idx][0] == sorted[idx][1] && sorted[idx][1] != sorted[idx][2] && sorted[idx][2] == sorted[idx][4]) return 25;
            return 0;
        }
        if (cat == 10) {
            // cerr << "============" << endl;
            // cerr << "cat 10 start" << endl;
            for (int i = 0; i < 2; ++i) {
                int tmp = sorted[idx][i];
                for (int j = i+1; j < i+5; ++j) {
                    if (j == i+4) return 30;
                    if (sorted[idx][j] != tmp + 1) break;
                    tmp++;
                }
            }
            // cerr << "cat 10 return" << endl;
            return 0;
        }
        if (cat == 11) {
            int tmp = sorted[idx][0];
            for (int j = 1; j < 6; ++j) {
                if (j == 5) return 40;
                if (sorted[idx][j] != tmp+1) break;
                tmp++;
            }
            return 0;
        }
        if (cat == 12) {
            return sum;
        } 
        if (cat == 13) {
            if (sorted[idx][0] == sorted[idx][4])
                return 50;
            return 0;
        }
        assert(false);
        return 0;
    };

    int ans = 0;
    for (int i = 0; i < n-64; ++i) {
        int tmp = 0;
        for (int j = i; j < i + 65; j += 5) {
            tmp += score((j-i)/5+1, j);
        }
        ans = max(ans, tmp);
    }
    cout << ans << "\n";
}

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

	int t = 1;
    // cin >> t;
	while (t--) solve();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3784kb

input:

65
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1

output:

70

result:

ok single line: '70'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3868kb

input:

76
3 1 1 1 1 1 4 2 5 2 6 1 3 5 2 2 2
3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 1 1 1 2 2 1 2 3 4 5
1 2 3 4 5 1 1 6 1 6 6 6 6 1 1 1 1 1 4

output:

267

result:

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