# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139647 | almogwald | Combo (IOI18_combo) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include "job.h"
#define fori(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<n;i++)
#define forib(i,n) for(int i=n-1;i>=0;i--)
#define fornb(i,n) for(int i=n-1;i>0;i--)
#define maxl 10000000000
typedef long long lol;
using namespace std;
typedef vector<int> veci;
typedef pair<lol,lol> point;
lol sum=0;
vector<vector<int>> cons;
char ar[]={'A','B','X','Y'};
string guess_sequence(int n) {
string p = "";
for (int i = 0; i < 2 * n; ++i) {
p.push_back(ar[0]);
}
for (int i = 0; i < 2 * n; ++i) {
p.push_back(ar[1]);
}
string s="";
int coins = press(p);
p = "";
if(coins==0){
for (int i = 0; i < 4 * n; ++i) {
p.push_back(ar[2]);
}
coins = press(p);
p="";
if(coins==0){
s.push_back(ar[3]);
}else{
s.push_back(ar[2]);
}
}else{
for (int i = 0; i < 4 * n; ++i) {
p.push_back(ar[0]);
}
coins = press(p);
p="";
if(coins==0){
s.push_back(ar[1]);
}else{
s.push_back(ar[0]);
}
}
vector<char> arr;
fori(i,4){
if(ar[i]!=s[0]){
arr.push_back(ar[i]);
}
}
for (int i = 0; i < 4 * n; ++i) {
p.push_back(s[0]);
}
while(s.size()<n-1){
fori(i,4){
p[n*i+s.size()-1]=s.back();
}
fori(i,3){
p[n*i+s.size()]=arr[0];
p[n*i+s.size()+1]=arr[i];
}
p[3*n+s.size()]=arr[1];
coins = press(p);
if(coins==s.size()){
s.push_back(arr[2]);
}
if(coins==s.size()+1){
s.push_back(arr[1]);
}
if(coins==s.size()+2){
s.push_back(arr[0]);
}
}
if(s.size()<n){
p="";
for (int i = 0; i < 4 * n; ++i) {
p.push_back(s[0]);
}
fori(i,n-1){
p[i]=s[i];
}
p[n-1]=arr[0];
coins = press(p);
if(coins==n){
s.push_back(arr[0]);
}else{
p[n-1]=arr[1];
coins = press(p);
if(coins==n){
s.push_back(arr[1]);
}else{
s.push_back(arr[2]);
}
}
}
return s;
}