This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//bs:flags:grader.cpp
#include "Ali.h"
#include "Benjamin.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;
template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;
#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;
const int N = 1e4 + 10;
int n;
vector<int> g[N];
void Init(int n_, vector<int> u, vector<int> v) {
n = n_;
for (int i = 0; i < n - 1; ++i) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; ++i) {
SetID(i, i);
}
}
int get_forward(int x, int y) {
return y * (y + 1) / 2 + x;
}
pair<int, int> get_backward(int num) {
int lef = 0, rig = n;
while (rig - lef > 1) {
int mid = (lef + rig) / 2;
if (mid * (mid + 1) / 2 <= num) {
lef = mid;
} else {
rig = mid;
}
}
return {num - lef * (lef + 1) / 2, lef};
}
int dfs(int u, int w, int p = -1) {
if (u == w) {
return 0;
}
for (int v : g[u]) {
if (v != p) {
int ans = dfs(v, w, u);
if (ans != -1) {
return ans + 1;
}
}
}
return -1;
}
string SendA(string s) {
int msk = 0;
for (int i = 0; i < 20; ++i) {
msk |= (s[i] - '0') << (19 - i);
}
string ans;
while (msk < get_forward(0, n)) {
auto [x, y] = get_backward(msk);
ans += to_string(bitset<14>(dfs(x, y)));
msk += (1 << 20);
}
return ans;
}
int x, y;
string SendB(int n_, int x_, int y_) {
n = n_, x = x_, y = y_;
if (x > y) {
swap(x, y);
}
return to_string(bitset<20>(get_forward(x, y) % (1 << 20)));
}
int Answer(string t) {
int where = get_forward(x, y) / (1 << 20);
int msk = 0;
for (int i = 0; i < 14; ++i) {
msk |= (t[where * 14 + i] - '0') << (13 - i);
}
return msk;
}
//bs:flags:grader.cpp
#include "Ali.h"
#include "Benjamin.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;
template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;
#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;
const int N = 1e4 + 10;
int n;
vector<int> g[N];
void Init(int n_, vector<int> u, vector<int> v) {
n = n_;
for (int i = 0; i < n - 1; ++i) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; ++i) {
SetID(i, i);
}
}
int get_forward(int x, int y) {
return y * (y + 1) / 2 + x;
}
pair<int, int> get_backward(int num) {
int lef = 0, rig = n;
while (rig - lef > 1) {
int mid = (lef + rig) / 2;
if (mid * (mid + 1) / 2 <= num) {
lef = mid;
} else {
rig = mid;
}
}
return {num - lef * (lef + 1) / 2, lef};
}
int dfs(int u, int w, int p = -1) {
if (u == w) {
return 0;
}
for (int v : g[u]) {
if (v != p) {
int ans = dfs(v, w, u);
if (ans != -1) {
return ans + 1;
}
}
}
return -1;
}
string SendA(string s) {
int msk = 0;
for (int i = 0; i < 20; ++i) {
msk |= (s[i] - '0') << (19 - i);
}
string ans;
while (msk < get_forward(0, n)) {
auto [x, y] = get_backward(msk);
ans += to_string(bitset<14>(dfs(x, y)));
msk += (1 << 20);
}
return ans;
}
int x, y;
string SendB(int n_, int x_, int y_) {
n = n_, x = x_, y = y_;
if (x > y) {
swap(x, y);
}
return to_string(bitset<20>(get_forward(x, y) % (1 << 20)));
}
int Answer(string t) {
int where = get_forward(x, y) / (1 << 20);
int msk = 0;
for (int i = 0; i < 14; ++i) {
msk |= (t[where * 14 + i] - '0') << (13 - i);
}
return msk;
}
Compilation message (stderr)
Ali.cpp: In function 'std::string SendA(std::string)':
Ali.cpp:79:41: error: no matching function for call to 'to_string(std::bitset<14>)'
79 | ans += to_string(bitset<14>(dfs(x, y)));
| ^
In file included from /usr/include/c++/10/string:55,
from Ali.h:1,
from Ali.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6587:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6587 | to_string(int __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6587:17: note: no known conversion for argument 1 from 'std::bitset<14>' to 'int'
6587 | to_string(int __val)
| ~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6598:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6598 | to_string(unsigned __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6598:22: note: no known conversion for argument 1 from 'std::bitset<14>' to 'unsigned int'
6598 | to_string(unsigned __val)
| ~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6606:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6606 | to_string(long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6606:18: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long int'
6606 | to_string(long __val)
| ~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6617:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6617 | to_string(unsigned long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6617:27: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long unsigned int'
6617 | to_string(unsigned long __val)
| ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6625:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6625 | to_string(long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6625:23: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long long int'
6625 | to_string(long long __val)
| ~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6637:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6637 | to_string(unsigned long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6637:32: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long long unsigned int'
6637 | to_string(unsigned long long __val)
| ~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6648:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
6648 | to_string(float __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6648:19: note: no known conversion for argument 1 from 'std::bitset<14>' to 'float'
6648 | to_string(float __val)
| ~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6657:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
6657 | to_string(double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6657:20: note: no known conversion for argument 1 from 'std::bitset<14>' to 'double'
6657 | to_string(double __val)
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6666:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
6666 | to_string(long double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6666:25: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long double'
6666 | to_string(long double __val)
| ~~~~~~~~~~~~^~~~~
Ali.cpp: In function 'std::string SendB(int, int, int)':
Ali.cpp:92:60: error: no matching function for call to 'to_string(std::bitset<20>)'
92 | return to_string(bitset<20>(get_forward(x, y) % (1 << 20)));
| ^
In file included from /usr/include/c++/10/string:55,
from Ali.h:1,
from Ali.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6587:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6587 | to_string(int __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6587:17: note: no known conversion for argument 1 from 'std::bitset<20>' to 'int'
6587 | to_string(int __val)
| ~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6598:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6598 | to_string(unsigned __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6598:22: note: no known conversion for argument 1 from 'std::bitset<20>' to 'unsigned int'
6598 | to_string(unsigned __val)
| ~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6606:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6606 | to_string(long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6606:18: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long int'
6606 | to_string(long __val)
| ~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6617:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6617 | to_string(unsigned long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6617:27: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long unsigned int'
6617 | to_string(unsigned long __val)
| ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6625:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6625 | to_string(long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6625:23: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long long int'
6625 | to_string(long long __val)
| ~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6637:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6637 | to_string(unsigned long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6637:32: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long long unsigned int'
6637 | to_string(unsigned long long __val)
| ~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6648:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
6648 | to_string(float __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6648:19: note: no known conversion for argument 1 from 'std::bitset<20>' to 'float'
6648 | to_string(float __val)
| ~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6657:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
6657 | to_string(double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6657:20: note: no known conversion for argument 1 from 'std::bitset<20>' to 'double'
6657 | to_string(double __val)
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6666:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
6666 | to_string(long double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6666:25: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long double'
6666 | to_string(long double __val)
| ~~~~~~~~~~~~^~~~~
grader_ali.cpp:10:8: warning: '{anonymous}::_randmem' defined but not used [-Wunused-variable]
10 | char _randmem[12379];
| ^~~~~~~~
Benjamin.cpp: In function 'std::string SendA(std::string)':
Benjamin.cpp:79:41: error: no matching function for call to 'to_string(std::bitset<14>)'
79 | ans += to_string(bitset<14>(dfs(x, y)));
| ^
In file included from /usr/include/c++/10/string:55,
from Ali.h:1,
from Benjamin.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6587:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6587 | to_string(int __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6587:17: note: no known conversion for argument 1 from 'std::bitset<14>' to 'int'
6587 | to_string(int __val)
| ~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6598:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6598 | to_string(unsigned __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6598:22: note: no known conversion for argument 1 from 'std::bitset<14>' to 'unsigned int'
6598 | to_string(unsigned __val)
| ~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6606:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6606 | to_string(long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6606:18: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long int'
6606 | to_string(long __val)
| ~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6617:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6617 | to_string(unsigned long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6617:27: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long unsigned int'
6617 | to_string(unsigned long __val)
| ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6625:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6625 | to_string(long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6625:23: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long long int'
6625 | to_string(long long __val)
| ~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6637:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6637 | to_string(unsigned long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6637:32: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long long unsigned int'
6637 | to_string(unsigned long long __val)
| ~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6648:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
6648 | to_string(float __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6648:19: note: no known conversion for argument 1 from 'std::bitset<14>' to 'float'
6648 | to_string(float __val)
| ~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6657:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
6657 | to_string(double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6657:20: note: no known conversion for argument 1 from 'std::bitset<14>' to 'double'
6657 | to_string(double __val)
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6666:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
6666 | to_string(long double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6666:25: note: no known conversion for argument 1 from 'std::bitset<14>' to 'long double'
6666 | to_string(long double __val)
| ~~~~~~~~~~~~^~~~~
Benjamin.cpp: In function 'std::string SendB(int, int, int)':
Benjamin.cpp:92:60: error: no matching function for call to 'to_string(std::bitset<20>)'
92 | return to_string(bitset<20>(get_forward(x, y) % (1 << 20)));
| ^
In file included from /usr/include/c++/10/string:55,
from Ali.h:1,
from Benjamin.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6587:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6587 | to_string(int __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6587:17: note: no known conversion for argument 1 from 'std::bitset<20>' to 'int'
6587 | to_string(int __val)
| ~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6598:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6598 | to_string(unsigned __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6598:22: note: no known conversion for argument 1 from 'std::bitset<20>' to 'unsigned int'
6598 | to_string(unsigned __val)
| ~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6606:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6606 | to_string(long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6606:18: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long int'
6606 | to_string(long __val)
| ~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6617:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6617 | to_string(unsigned long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6617:27: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long unsigned int'
6617 | to_string(unsigned long __val)
| ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6625:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6625 | to_string(long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6625:23: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long long int'
6625 | to_string(long long __val)
| ~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6637:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6637 | to_string(unsigned long long __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6637:32: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long long unsigned int'
6637 | to_string(unsigned long long __val)
| ~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6648:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
6648 | to_string(float __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6648:19: note: no known conversion for argument 1 from 'std::bitset<20>' to 'float'
6648 | to_string(float __val)
| ~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6657:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
6657 | to_string(double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6657:20: note: no known conversion for argument 1 from 'std::bitset<20>' to 'double'
6657 | to_string(double __val)
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:6666:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
6666 | to_string(long double __val)
| ^~~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6666:25: note: no known conversion for argument 1 from 'std::bitset<20>' to 'long double'
6666 | to_string(long double __val)
| ~~~~~~~~~~~~^~~~~