QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#797639#9808. Fragile Pinballucup-team4975#WA 60ms16676kbC++232.5kb2024-12-03 15:31:332024-12-03 15:31:33

Judging History

This is the latest submission verdict.

  • [2024-12-03 15:31:33]
  • Judged
  • Verdict: WA
  • Time: 60ms
  • Memory: 16676kb
  • [2024-12-03 15:31:33]
  • Submitted

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
    cerr << setw(4) << #x << ":: "; \
    for (auto i : x)                \
        cerr << i << " ";           \
    cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
    out << x.fir << " " << x.sec << endl;
    return out;
}

const int mod = 998244353;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 200020;
ll dp[(1 << 16) + 10][16], ans[(1 << 16) + 10];
int vis[(1 << 16) + 10][16];
int op[9] = {1, 2, 4, 8, 3, 12, 5, 10, 15};
int val[9];
void solve()
{
    int n, now = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	string s1, s2;
    	cin >> s1 >> s2;
    	int res = (s1[0] - '0') + (s1[1] - '0') * 2 + (s2[0] - '0') * 4 + (s2[1] - '0') * 8;
    	now = (now | res);
    }
    ll as = inf;
    for (int i = 1; i < (1 << 16); i++) {
    	if ((i & now) == now) {
    		bitset<16>b = i;
    		// cout << i << " " << b << " " << ans[i]<< el;
    		as = min(as, ans[i]);
    	}
    }
    cout << as << el;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    int a1, a2, a3, a4;
    cin >> a1 >> a2 >> a3 >> a4;
    val[0] = val[1] = val[2] = val[3] = a1;
    val[4] = val[5] = a2;
    val[6] = val[7] = a3;
    val[8] = a4;
    
    for (int i = 0;  i < (1 << 16); i++) {
    	for (int j = 0; j < 16; j++) {
    		dp[i][j] = inf;
    	}
    	ans[i] = inf;
    }

    priority_queue<pair<PII, int>> q;
    dp[0][0] = 0;
    q.push({{0, 0}, 0});

    while (!q.empty()) {
    	auto [x, vl] = q.top();
    	q.pop();
    	if (vis[x.fir][x.sec])
    		continue;
    	vis[x.fir][x.sec] = 1;
    	ans[x.fir] = min(ans[x.fir], dp[x.fir][x.sec]);
    	for (int i = 0; i < 9; i++) {
    		int state = x.sec ^ op[i];
    		int st = (x.fir | (1 << state));
    		if (vis[st][state])
    			continue;
    		int v = dp[x.fir][x.sec] + val[i];
    		if (v < dp[st][state]) {
    			dp[st][state] = v;
    			q.push({{st, state}, v});
    		}
    	}
    }

    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 60ms
memory: 16676kb

input:

3
4 0
0 3
0 -1

output:

0
0
0

result:

wrong answer 1st numbers differ - expected: '5.0000000', found: '0.0000000', error = '1.0000000'