# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
885767 | Zero | 아름다운 순열 (IZhO12_beauty) | C++17 | 600 ms | 440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int bt(int n){
return __builtin_popcount(n);
}
int tr(int n){
int y = 0;
while(n){
if(n%3==1) y++;
n/=3;
}
return y;
}
bool ok(vector<int> a){
for(int i=0; i < a.size()-1; i ++){
int b1 = bt(a[i]), t1 = tr(a[i]);
int b2 = bt(a[i+1]), t2 = tr(a[i+1]);
if(!(b1 == b2 || t1 == t2)) return 0;
}
return 1;
}
int main() {
int n; cin >> n;
vector<int> a(n);
for(auto &i : a ) cin >> i;
sort(a.begin(),a.end());
int c = 0;
do{
c += ok(a);
}while(next_permutation(a.begin(),a.end()));
cout << c;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |