#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
inline int readInt() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();int n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline ll readLong() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();ll n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline string readString() {char c;while(c=getchar(),c==' '||c=='\n'||c=='\t');string s({c});while(c=getchar(),c!=EOF&&c!=' '&&c!='\n'&&c!='\t')s+=c;return s;}
const int MaxN = 10;
const int MaxM = 6;
int p[MaxN + 33];
int cnt[MaxN];
vector<std::pair<int, int>> Alice()
{
int n = MaxN;
mt19937 rng(129322);
rep(i, n) p[i] = i;
shuffle(p + 1, p + 1 + n, rng);
ll target = 10;
forn(i, 0, 60) cnt[i] = 0;
vector<int> bits;
forn(i, 0, 59) if(target >> i & 1)
bits.pb(i + 1);
vector<pii> res;
forn(i, 1, n - 1)
{
pii Min = {1e9, 0};
for(int x : bits)
minimize(Min, {cnt[x], x});
if(i <= Min.se) res.pb({p[i], p[n]});
else res.pb({p[i], p[i - Min.se]}), ++cnt[Min.se];
}
return res;
}
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
const int MaxN_ = 10;
const int MaxM_ = 6;
int p_[MaxN_ + 33], pos[MaxN_ + 33];
long long Bob(std::vector<std::pair<int, int>> V)
{
int n = MaxN_;
mt19937 rng(129322);
rep(i, n) p_[i] = i;
shuffle(p_ + 1, p_ + 1 + n, rng);
rep(i, n) pos[p_[i]] = i;
ll res = 0;
for(auto &[u, v] : V)
{
if(pos[u] == n || pos[v] == n) continue;
if(pos[u] > pos[v]) swap(u, v);
if(pos[v] - pos[u] > 59) continue;
res |= 1ll << (pos[v] - pos[u] - 1);
}
return res;
}
Compilation message
Alice.cpp: In function 'std::vector<std::pair<int, int> > Alice()':
Alice.cpp:44:27: warning: iteration 10 invokes undefined behavior [-Waggressive-loop-optimizations]
44 | forn(i, 0, 60) cnt[i] = 0;
| ~~~~~~~^~~
Alice.cpp:8:42: note: within this loop
8 | #define forn(i, l, r) for(int i = (l); i <= (r); ++i)
| ^
Alice.cpp:44:5: note: in expansion of macro 'forn'
44 | forn(i, 0, 60) cnt[i] = 0;
| ^~~~
Alice.cpp:44:27: warning: 'void* __builtin_memset(void*, int, long unsigned int)' forming offset [40, 243] is out of the bounds [0, 40] of object 'cnt' with type 'int [10]' [-Warray-bounds]
44 | forn(i, 0, 60) cnt[i] = 0;
| ~~~~~~~^~~
Alice.cpp:33:5: note: 'cnt' declared here
33 | int cnt[MaxN];
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |