# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1121740 | rahidilbayramli | Calvinball championship (CEOI15_teams) | C++17 | 79 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define sz(v) (ll)(v.size())
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const ll mod = 1e6+7;
void solve()
{
ll n, i, j, k, l, r, f, p;
cin >> n;
ll a[n+5], cnt = 0;
for(i = 1; i <= n; i++){
cin >> a[i];
if(a[i] == i)
cnt++;
}
vector<vl>vect;
vl v;
for(i = 1; i <= n; i++)
v.pb(1);
ll pos = n - 1, pos2 = n - 1;
vect.pb(v);
while(true)
{
while(pos2 && v[pos2]-v[pos2-1] == 1)
{
pos2--;
}
v[pos2]++;
k = v[pos2];
for(j = pos2+1; j < n; j++)
{
k--;
v[j] = max(1LL, k);
}
pos2 = n - 1;
if(v[0] > 1)
break;
vect.pb(v);
}
bool ok = true;
cnt = 0;
for(auto u : vect)
{
cnt++;
ok = true;
for(j = 0; j < n; j++)
{
if(u[j] == a[j+1])
continue;
ok = false;
}
if(ok)
{
cout << cnt << "\n";
return;
}
}
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll tests = 1;
//cin >> tests;
while(tests--)
{
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |