# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1009077 | christinelynn | Commuter Pass (JOI18_commuter_pass) | C++17 | 2048 ms | 6492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
# define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"
const int cnst = 2e5+5;
bool mutipletestcase = 0;
bool debug = 0;
vector<int> act;
int ask(int x, int idx) {
cout << "? " << idx << " " << x << endl;
int a;
if(!debug) cin >> a;
else {
a = 0;
for(auto v: act)
if(idx <= v && (v+(v^idx)) == x) a = 1;
else if(idx > v && (v-(v^idx)) == x) a = 1;
}
return a;
// return 1;
}
void solve() {
int n; cin >> n;
if(debug) {
int k; cin >> k;
for(int i = 1; i<=k; i++) {
int a; cin >> a;
act.pb(a);
}
// cerr << 50+(50^31) << " " << 50+(50^32) << endl;
}
pair<int, int> uniq = {1, 1};
for(int j1 = 1; j1<=n; j1++) {
for(int j2 = 1; j2<=n; j2++) {
map<int, int> mp;
map<int, int> mp2;
bool yes = 1;
for(int k = 1; k<=n; k++) {
int a;
int b;
if(j1 <= k) a = k+(k^j1);
else a = k-(k^j1);
if(j2 <= k) b = k+(k^j2);
else b = k-(k^j2);
a += 1000;
b += 1000;
// cerr << k << " " << a << " " << b << endl;
mp[a]++;
mp2[b]++;
}
for(int k = 1; k<=n; k++) {
int a;
int b;
if(j1 <= k) a = k+(k^j1);
else a = k-(k^j1);
if(j2 <= k) b = k+(k^j2);
else b = k-(k^j2);
a += 1000;
b += 1000;
// cerr << k << " " << a << " " << b << endl;
if(mp[a] > 1 && mp2[b] > 1) yes = 0;
}
if(yes) {
cerr << j1 << " " << j2 << endl;
uniq = {j1, j2};
}
}
}
// cerr << uniq.fir << " " << uniq.sec << endl;
vector<int> ans;
for(int i = 1; i<=n; i++) {
int a;
int b;
if(uniq.fir <= i) a = i+(i^uniq.fir);
else a = i-(i^uniq.fir);
if(uniq.sec <= i) b = i+(i^uniq.sec);
else b = i-(i^uniq.sec);
// cerr << i << " " << a << " " << b << endl;
int c = ask(a, uniq.fir);
int d = ask(b, uniq.sec);
if(c && d) ans.pb(i);
}
cout << "! " << ans.size() << " ";
for(auto v: ans) cout << v << " "; cout << endl;
}
signed main() {
// ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
if(mutipletestcase) cin >> t;
while(t--) 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... |