Task: | Babaza Game |
Sender: | AleksandrPolitov |
Submission time: | 2024-09-02 17:34:23 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp:11:19: warning: overflow in conversion from 'double' to 'int' changes value from '4.0e+18' to '2147483647' [-Woverflow] 11 | const int LLINF = 4e18; // 4*10^18 is < 2^63-1 | ^~~~ input/code.cpp: In function 'bool check(std::string&)': input/code.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 18 | for (int i = 0; i < s.size()-1; i++) { | ~~^~~~~~~~~~~~ input/code.cpp: In function 'bool ok(std::string&)': input/code.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 25 | for (int i = 0; i < s.size()-1; i++) { | ~~^~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:46:23: warning: comparison of integer expressio...
Code
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i=a; i< (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define pb push_back typedef long long ll; const int INF = 1e9; // 10^9 = 1B is < 2^31-1 const int LLINF = 4e18; // 4*10^18 is < 2^63-1 const double EPS = 1e-9; const ll MOD = 1e9+7; vector<string> res(1000); bool check(string &s) { for (int i = 0; i < s.size()-1; i++) { if(s[i]==s[i+1]) return true; } return false; } bool ok(string &s) { for (int i = 0; i < s.size()-1; i++) { if(s[i]==s[i+1]) return false; } return true; } std::set<char> nonUsed; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); string a, b; std::cin >> a >> b; int n=a.size(); for (int i = 0; i < 26; i++) { nonUsed.insert((char)('A'+i)); } for (int i = 0; i < a.size(); i++) { nonUsed.erase(a[i]); nonUsed.erase(b[i]); } // None if(a==b) { std::cout << a << std::endl; return 0; } // even { bool status=true; string tmp=a; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } if(!ok(tmp) || tmp!=b) status=false; if(status) { std::cout << a << std::endl; std::cout << b << std::endl; return 0; } } // odd { bool status=true; string tmp=a; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } if(!ok(tmp) || tmp!=b) status=false; if(status && tmp==b) { std::cout << a << std::endl; std::cout << b << std::endl; return 0; } } // even -> odd { vector<string> res; res.pb(a); bool status=true; string tmp=a; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } res.pb(tmp); if(!ok(tmp)) status=false; if(b!=tmp) res.pb(b); if(status && res.back()==b) { for(auto &w:res) { std::cout << w << std::endl; } return 0; } } // odd -> even { vector<string> res; res.pb(a); bool status=true; string tmp=a; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { tmp[i]=b[i]; } } res.pb(tmp); if(!ok(tmp)) status=false; if(b!=tmp) res.pb(b); if(status && res.back()==b) { for(auto &w:res) { std::cout << w << std::endl; } return 0; } } // even -> odd -> even { vector<string> res; res.pb(a); bool status=true; string tmp=a; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; if(status && res.back()==b) { for(auto &w:res) { std::cout << w << std::endl; } return 0; } } // odd -> even -> odd { vector<string> res; res.pb(a); bool status=true; string tmp=a; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 0; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; for (int i = 1; i < n; i+=2) { if(tmp[i]!=b[i]) { bool can=true; if(i+1<n) can&=tmp[i+1]!=b[i]; if(i-1>=0) can&=tmp[i-1]!=b[i]; if(can) { tmp[i]=b[i]; } else { tmp[i]=*nonUsed.begin(); } } } res.pb(tmp); if(!ok(tmp)) status=false; if(status && res.back()==b) { for(auto &w:res) { std::cout << w << std::endl; } return 0; } } return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
A B |
correct output |
---|
A B |
user output |
---|
A B |
Test 2
Verdict: ACCEPTED
input |
---|
BABAZA BACBCB |
correct output |
---|
BABAZA BACACA BACBCB |
user output |
---|
BABAZA BACACA BACBCB |
Test 3
Verdict: ACCEPTED
input |
---|
AB BA |
correct output |
---|
AB CB CA BA |
user output |
---|
AB CB CA BA |
Test 4
Verdict: ACCEPTED
input |
---|
ABC BCD |
correct output |
---|
ABC DBD DCD BCD |
user output |
---|
ABC EBD ECD BCD |
Test 5
Verdict: WRONG ANSWER
input |
---|
AXYB CXYD |
correct output |
---|
AXYB CXYD |
user output |
---|
AXYB CXYB CXYD |
Test 6
Verdict: ACCEPTED
input |
---|
LMIJLF PAQBMH |
correct output |
---|
LMIJLF PMQJMF PAQBMH |
user output |
---|
LMIJLF PMQJMF PAQBMH |
Test 7
Verdict: ACCEPTED
input |
---|
PNIWLSLIH CRLVPUFHD |
correct output |
---|
PNIWLSLIH CNLWPSFID CRLVPUFHD |
user output |
---|
PNIWLSLIH CNLWPSFID CRLVPUFHD |
Test 8
Verdict: ACCEPTED
input |
---|
ZDYIAVTKL ZJKVXGAUM |
correct output |
---|
ZDYIAVTKL ZJYVAGTUL ZJKVXGAUM |
user output |
---|
ZDYIAVTKL ZDKIXVAKM ZJKVXGAUM |
Test 9
Verdict: ACCEPTED
input |
---|
FBIXISJH NXZIESMG |
correct output |
---|
FBIXISJH NBZXESMH NXZIESMG |
user output |
---|
FBIXISJH NBZXESMH NXZIESMG |
Test 10
Verdict: ACCEPTED
input |
---|
OPGW QJIE |
correct output |
---|
OPGW QPIW QJIE |
user output |
---|
OPGW QPIW QJIE |
Test 11
Verdict: ACCEPTED
input |
---|
DUKNPKQZBL NZPBMOEBIC |
correct output |
---|
DUKNPKQZBL NUPNMKEZIL NZPBMOEBIC |
user output |
---|
DUKNPKQZBL NUPNMKEZIL NZPBMOEBIC |
Test 12
Verdict: ACCEPTED
input |
---|
ZWDTX HZOXI |
correct output |
---|
ZWDTX HWOTI HZOXI |
user output |
---|
ZWDTX HWOTI HZOXI |
Test 13
Verdict: ACCEPTED
input |
---|
URJF ITIQ |
correct output |
---|
URJF IRIF ITIQ |
user output |
---|
URJF IRIF ITIQ |
Test 14
Verdict: ACCEPTED
input |
---|
WYWBWU IRYVBA |
correct output |
---|
WYWBWU WRWVWA IRYVBA |
user output |
---|
WYWBWU WRWVWA IRYVBA |