# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373189 | sams | Zoltan (COCI16_zoltan) | C++14 | 775 ms | 65540 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7, maxn = 2e5+10;
int n, v[maxn];
map<ll, bool> ck;
int main()
{
scanf("%d", &n);
vector<int> g;
for(int i = 1 ; i <=n ; ++i) scanf("%d", &v[i]);
// checar todas as posições
vector<ll> row1, row2, ver;
row1.push_back(v[1]);
for(int i = 2 ; i <= n ; ++i)
{
for(auto j: row1)
{
ll num = j * 10 + v[i];
if(!ck[num])
{
ck[num] = 1;
if(i == n) ver.push_back(num);
else row2.push_back(num);
}
ll y = j; num = 1;
while(y > 0)
{
ll a = y % 10;
y -= a; y /= 10; num *= 10;
}
num *= v[i]; num += j;
if(!ck[num])
{
ck[num] = 1;
if(i == n) ver.push_back(num);
else row2.push_back(num);
}
}
row1.clear(); row1 = row2; row2.clear();
}
cout << ver.size() << '\n';
for(auto x: ver) { cout << x << '\n'; }
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |