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>
#define f first
#define s second
#define pb push_back
#define len(x) x.size()
#define debug(x) cout << #x << " is " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N = 32;
const ll oo = 1e9 + 7;
const ll valid[10] = {8 + 2, 2, 8 + 1, 1 + 2 + 4, 2 + 16, 1 + 4 + 16, 8 + 4, 1 + 2, 1 + 4 + 8 + 16, 1 + 2 + 4 + 16};
ll sum(ll x, ll y)
{
return (x + y) % oo;
}
ll mult(ll x, ll y)
{
return (x * y) % oo;
}
vector <vector <ll> > mult(vector <vector <ll> > a, vector <vector <ll> > b)
{
vector <vector <ll> > c;
c.resize(N);
for (ll i = 0; i < N; i++) c[i].resize(N);
for (ll i = 0; i < N; i++)
for (ll j = 0; j < N; j++)
{
c[i][j] = 0;
for (ll c1 = 0; c1 < N; c1++) c[i][j] = sum(c[i][j], mult(a[i][c1], b[c1][j]));
}
return c;
}
vector <vector <ll> > binpow(vector <vector <ll> > c, ll k)
{
if (k == 1) return c;
if (k & 1) return mult(c, binpow(c, k - 1));
else
{
vector <vector <ll> > c1 = binpow(c, k / 2);
return mult(c1, c1);
}
}
int main()
{
int n, k;
cin >> n >> k;
for (int i = 0; i < n - 1; i++)
{
int x, y;
cin >> x >> y;
}
n = k;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
vector <int> ans;
int i = 0;
while (i < n)
{
if (i == n - 1)
{
ans.pb(a[i]);
i++;
break;
}
if (!((a[i + 1] - a[i]) & 1))
{
ans.pb((a[i + 1] + a[i]) / 2);
i += 2;
}
else
{
ans.pb(a[i]);
i++;
}
}
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
cout << endl;
}
Compilation message (stderr)
pastiri.cpp: In function 'int main()':
pastiri.cpp:86:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
86 | for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |