| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1325235 | askeww | 질문 (CEOI14_question_grader) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using V = vector<T>;
const int B = 12;
int TP, n, t, x, y, q, h;
V<int> s;
int main() {
for (int i = 0; i < (1 << B); i++) {
if (__builtin_popcount(i) == B / 2) {
s.push_back(i);
}
}
cin >> TP;
if (TP == 1) {
cin >> n >> t;
while (t--) {
cin >> x >> y;
for (int i = 0; i < B; i++) {
if ((s[x] & (1 << i)) && !(s[y] & (1 << i))) {
cout << (i + 1) << endl; // If s[q] contains i, "yes"
break;
}
}
}
} else {
cin >> n >> t;
while (t--) {
cin >> q >> h;
h--;
if (s[q] & (1 << h)) {
cout << "yes" << endl;
} else {
cout << "no" << endl;
}
}
}
}#include <bits/stdc++.h>
using namespace std;
template<typename T>
using V = vector<T>;
const int B = 12;
int TP, n, t, x, y, q, h;
V<int> s;
int main() {
for (int i = 0; i < (1 << B); i++) {
if (__builtin_popcount(i) == B / 2) {
s.push_back(i);
}
}
cin >> TP;
if (TP == 1) {
cin >> n >> t;
while (t--) {
cin >> x >> y;
for (int i = 0; i < B; i++) {
if ((s[x] & (1 << i)) && !(s[y] & (1 << i))) {
cout << (i + 1) << endl; // If s[q] contains i, "yes"
break;
}
}
}
} else {
cin >> n >> t;
while (t--) {
cin >> q >> h;
h--;
if (s[q] & (1 << h)) {
cout << "yes" << endl;
} else {
cout << "no" << endl;
}
}
}
}