QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#280543 | #7789. Outro: True Love Waits | ucup-team1069# | WA | 4ms | 50360kb | C++23 | 1.7kb | 2023-12-09 16:50:07 | 2023-12-09 16:50:08 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef long long ll;
const int N = 1e6 + 2;
set<int> g[N];
const int K = 10;
int sz = 0;
int need = (1 << 8);
const int mod = 1e9 + 7;
void dfs(int v) {
if (v == need) cout << sz << '\n';
sz++;
//cout << (k++) << ": " << (bitset<K>(v)) << '\n';
if (g[v].size()) {
int i = *g[v].begin();
g[v].erase(i);
g[v^(1<<i)].erase(i);
dfs(v ^ (1<<i));
}
}
void solve() {
map<string, long long> val;
val["00"] = 0;
val["10"] = 1;
val["11"] = 2;
val["01"] = 3;
string s, t;
int k;
cin >> s >> t >> k;
reverse(all(s));
reverse(all(t));
while (sz(s) < max(sz(s), sz(t))) s += "0";
while (sz(t) < max(sz(s), sz(t))) t += "0";
for (int i = 0; i < sz(s); ++i) {
if (s[i] == '1') t[i] ^= 1;
}
if (sz(t) & 1) t += "0";
long long pos = 0, pw = 1, now = 0;
for (int i = 0; i < sz(t); i += 2) {
if (val[t.substr(i, 2)] == 0 && now * 2 == i) {
now++;
}
pos += (pw * val[t.substr(i, 2)]) % mod;
pos %= mod;
pw *= 5;
pw %= mod;
}
if (now * 2 == sz(t)) now = k + 1000;
if (now + 1 < k) {
cout << -1 << '\n';
return;
}
pw = 4;
while (--k) {
pos = (pos + pw) % mod;
pw = (pw * 4) % mod;
}
cout << pos << '\n';
}
int main() {
/*
for (int i = 0; i < (1 << K); ++i) {
for (int j = 0; j < K; ++j) {
g[i].insert(j);
}
}
dfs(0);
*/
int T = 0;
cin >> T;
while (T--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 50312kb
input:
4 1 10 1 1 10 2 100 0 2 11 11 3
output:
2 -1 9 20
result:
ok 4 number(s): "2 -1 9 20"
Test #2:
score: 0
Accepted
time: 4ms
memory: 50340kb
input:
1 0 0 1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 50360kb
input:
100 110111 11111 1 10110 101101 1 11010 111111 1 100110 1 1 10010 11010 1 1100 10111 1 100100 111110 1 101110 101100 1 1011 10110 1 110100 1110 1 11010 11000 1 11110 1000 1 111000 11101 1 110 1001 1 101010 11000 1 10 111110 1 110001 101000 1 1010 1000 1 10101 11 1 111011 11010 1 110001 100000 1 1100...
output:
90 67 81 82 15 42 43 3 36 68 3 33 81 12 53 60 41 3 33 76 26 43 62 81 77 31 37 88 38 18 65 13 93 15 27 82 81 40 18 27 33 50 81 62 6 0 75 3 33 15 10 16 92 28 41 67 83 13 27 35 25 38 27 56 25 55 7 52 50 3 41 87 67 33 63 43 33 32 33 82 63 16 62 55 28 18 91 68 8 30 76 66 36 6 8 41 2 80 50 52
result:
wrong answer 1st numbers differ - expected: '78', found: '90'