QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454741 | #8523. Puzzle II | YeongTree | WA | 1ms | 5572kb | C++14 | 1.4kb | 2024-06-25 12:35:07 | 2024-06-25 12:35:08 |
Judging History
answer
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define plll pair<long long, pll>
#define tiii array<int, 3>
#define tiiii array<int, 4>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
typedef long long ll;
typedef long double ld;
const int INF = (int)1e9 + 7;
using namespace std;
int n, k;
int A[303030];
int B[303030];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for(int i = 0; i < n; ++i)
{
char c; cin >> c;
A[i] = (c == 'B');
}
for(int i = 0; i < n; ++i)
{
char c; cin >> c;
B[i] = (c == 'B');
}
int cnt = 0;
for(int i = 0; i < n; ++i) if(A[i]) ++cnt;
bool f = (cnt <= n / 2);
vector<int> C, D;
for(int i = 0; i < n; ++i) if(A[i] == f) C.push_back(i);
for(int i = n - 1; i >= 0; --i) if(B[i] != f) D.push_back(i);
int t = C.size();
assert(t == D.size());
vector<int> E, F;
vector<pii> G;
for(int i = 0; i < t; ++i)
{
int x = C[i] + (E.end() - lower_bound(E.begin(), E.end(), -C[i] - k));
int y = D[i] - (F.end() - lower_bound(F.begin(), F.end(), D[i] - k + 1));
E.push_back(-x);
F.push_back(y);
G.push_back({x, y});
}
cout << 2 * t << '\n';
for(auto [x, y] : G)
{
cout << (n + x - k) % n + 1 << ' ' << y + 1 << '\n';
cout << (n + x - k + 1) % n + 1 << ' ' << y + 1 << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5572kb
input:
6 3 BCCBCC BBCBBC
output:
4 4 6 5 6 2 2 3 2
result:
wrong answer The final sequences are not correct!