One does not simply do CP well in NNN
This commit is contained in:
parent
cacc165173
commit
b38d9929f7
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
seq = [0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, 2, 9,
|
||||
0, 4, 9, 3, 6, 14, 0, 6, 3, 5, 15, 0, 5, 3, 5, 2, 17, 0, 6, 11, 0, 3, 8,
|
||||
0, 3, 3, 1, 42, 0, 5, 15, 20, 0, 4, 32, 0, 3, 11, 18, 0, 4, 7, 0, 3, 7,
|
||||
3, 2, 31, 0, 6, 31, 3, 6, 3, 2, 8, 33, 0, 9, 56, 0, 3, 8, 7, 19, 0, 5,
|
||||
37, 0, 3, 8, 8, 1, 46, 0, 6, 23, 0, 3, 9, 21, 0, 4, 42, 56, 25, 0, 5,
|
||||
21, 8, 18, 52, 0, 6, 18, 4, 13, 0, 5, 11, 62, 0, 4, 7]
|
||||
for t in range(int(input())):
|
||||
print((lambda n: seq[:n].count(seq[n-1]))(int(input())))
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from functools import reduce
|
||||
|
||||
for t in range(int(input())):
|
||||
print(bin(reduce(int.__xor__, (int(input(), 2)
|
||||
for i in range(int(input()))))).count('1'))
|
|
@ -0,0 +1 @@
|
|||
put [+] ([+^] (^get).map: {:2(get)}).base(2).comb for ^get
|
|
@ -1,3 +1,4 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
|
@ -13,8 +14,16 @@ neg_length ()
|
|||
catch (bad_alloc) { cout << "BIG OOF!" << endl; }
|
||||
}
|
||||
|
||||
void
|
||||
init ()
|
||||
{
|
||||
Vector v {7.4, 3.2, 5.2, 6.9, 9.5, 4.2, 21.7};
|
||||
assert(v[5] == 4.2);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
neg_length ();
|
||||
init ();
|
||||
}
|
||||
|
|
|
@ -12,14 +12,27 @@ Vector::Vector (int s)
|
|||
sz = s;
|
||||
}
|
||||
|
||||
double& Vector::operator[] (int i)
|
||||
Vector::Vector (initializer_list<double> lst)
|
||||
: elem {new double[lst.size()]}, sz {static_cast<int> (lst.size())}
|
||||
{
|
||||
copy(lst.begin(), lst.end(), elem);
|
||||
}
|
||||
|
||||
Vector::~Vector ()
|
||||
{
|
||||
delete[] elem;
|
||||
}
|
||||
|
||||
int
|
||||
Vector::size () noexcept
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
double&
|
||||
Vector::operator[] (int i)
|
||||
{
|
||||
if (i < 0 || size() <= i)
|
||||
throw out_of_range{"Vector::operator[]"};
|
||||
return elem[i];
|
||||
}
|
||||
|
||||
int Vector::size () noexcept
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
class Vector {
|
||||
public:
|
||||
Vector (int s);
|
||||
Vector (std::initializer_list<double>);
|
||||
~Vector ();
|
||||
double& operator[] (int i);
|
||||
int size () noexcept;
|
||||
void push_back (double);
|
||||
private:
|
||||
double* elem;
|
||||
int sz;
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unordered_map<char, size_t> charmap;
|
||||
typedef set<char> charset;
|
||||
|
||||
constexpr double INF = 1e7;
|
||||
const charset VOWELS {'a', 'e', 'i', 'o', 'u'};
|
||||
|
||||
inline size_t
|
||||
sqr (size_t i)
|
||||
{
|
||||
return i * i;
|
||||
}
|
||||
|
||||
bool
|
||||
isvowel (const string& s, size_t i)
|
||||
{
|
||||
try { return VOWELS.count (s.at (i)); }
|
||||
catch (out_of_range const& e) { return true; }
|
||||
}
|
||||
|
||||
void
|
||||
update (const string& s, charmap& x, charmap& f)
|
||||
{
|
||||
charset b;
|
||||
for (const auto& c : s)
|
||||
{
|
||||
f[c]++;
|
||||
b.insert (c);
|
||||
}
|
||||
for (const auto& c : b)
|
||||
x[c]++;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
size_t t, l;
|
||||
string s;
|
||||
|
||||
cin >> t;
|
||||
while (t--)
|
||||
{
|
||||
charmap xa, fa, xb, fb;
|
||||
cin >> l;
|
||||
while (l--)
|
||||
{
|
||||
cin >> s;
|
||||
size_t i = s.size ();
|
||||
bool a = true;
|
||||
|
||||
while (i--)
|
||||
if (isvowel (s, i - 1) + isvowel (s, i) + isvowel (s, i + 1) < 2)
|
||||
{
|
||||
update (s, xb, fb);
|
||||
a = false;
|
||||
break;
|
||||
}
|
||||
if (a)
|
||||
update (s, xa, fa);
|
||||
}
|
||||
|
||||
double sc = 1.0;
|
||||
for (const auto& p : xa)
|
||||
sc *= p.second;
|
||||
for (const auto& p : fa)
|
||||
sc /= sqr (p.second);
|
||||
for (const auto& p : xb)
|
||||
sc /= p.second;
|
||||
for (const auto& p : fb)
|
||||
sc *= sqr (p.second);
|
||||
if (sc > INF)
|
||||
cout << "Infinity" << endl;
|
||||
else
|
||||
cout << sc << endl;
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 190a5c33aea5591698686c1db5fe44b0619e1b94
|
||||
Subproject commit 142d97f52b76bb8a02551636972db8b0747e1658
|
Loading…
Reference in New Issue