| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 89291 | abil | 아름다운 순열 (IZhO12_beauty) | C++14 | 301 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
Solution by Abil
**/
# include <bits/stdc++.h>
////////////////////////
# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long
using namespace std;
const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
vector<int > v;
int f(int x){
int cnt = 0;
while(x){
if(x % 3 == 1){
cnt++;
}
x = x / 3;
}
return cnt;
}
main()
{
int n, x;
cin >> n;
for(int i = 1;i <= n; i++){
cin >> x;
v.pb(x);
}
sort(all(v));
int ans = 0;
do{
bool f1 = true;
for(int i = 0;i < sz(v) - 1; i++){
if((__builtin_popcount(v[i])) != (__builtin_popcount(v[i + 1])) && (f(v[i]) != f(v[i + 1]))){
f1 = false;
break;
}
}
if(f1){
ans++;
}
}
while(next_permutation(all(v)));
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
