#include "Annalib.h"
/*input
3
10 50
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
namespace {
int v[155];
int ans[155];
void setv(int i,vector<int> v){
REP(a,3) ans[i*3+a]=v[a];
}
int cnt[155];
bool hv[155];
}
void Anna( int N, long long X, int K, int P[] ){
int cur=0;
REP(i,60){
v[i]=(X>>(59-i))&1;
}
REP(i,N) cnt[i]=0,hv[i]=ans[i]=0;
REP(i,K){
cnt[P[i]/3]++;
hv[P[i]]=1;
}
REP(i,N/3){
if(!cnt[i]){
int val=v[cur]*2+v[cur+1];
if(val==2){
setv(i,{0,1,1});
}
else{
setv(i,{1,v[cur],v[cur+1]});
}
cur+=2;
}
else if(cnt[i]==1){
if(hv[i*3]){
if(!v[cur]) setv(i,{0,1,0});
else setv(i,{0,0,1});
++cur;
}
else if(hv[i*3+2]){
if(!v[cur]) setv(i,{0,1,0});
else setv(i,{1,1,0});
++cur;
}
else{
if(v[cur]){
setv(i,{0,0,1});
++cur;
}
else{
setv(i,{1,0,v[cur+1]});
cur+=2;
}
}
}
}
REP(i,N) Set(i,ans[i]);
}
#include "Brunolib.h"
/*input
3
10 50
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
namespace {
int len[] = { 0, 1, 1, 2, 2, 2, 1, 2 };
int val[] = { 0, 1, 0, 2, 0, 1, 1, 3 };
}
long long Bruno( int N, int A[] ){
ll ans=0;
vector<int> cur;
REP(i,N/3){
int c=A[i*3]*4+A[i*3+1]*2+A[i*3+2];
if(len[c]==1) cur.pb(val[c]);
else if(len[c]==2) cur.pb(val[c]/2),cur.pb(val[c]%2);
}
REP(i,60) ans=ans*2+cur[i];
return ans;
}
Compilation message
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:44:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
44 | REP(i,N) cnt[i]=0,hv[i]=ans[i]=0;
| ~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
2292 KB |
Output is correct - L* = 40 |
2 |
Correct |
33 ms |
2284 KB |
Output is correct - L* = 40 |
3 |
Correct |
30 ms |
2248 KB |
Output is correct - L* = 40 |
4 |
Correct |
31 ms |
2272 KB |
Output is correct - L* = 40 |
5 |
Correct |
32 ms |
2248 KB |
Output is correct - L* = 40 |
6 |
Correct |
30 ms |
2336 KB |
Output is correct - L* = 40 |
7 |
Correct |
30 ms |
2412 KB |
Output is correct - L* = 40 |
8 |
Correct |
30 ms |
2308 KB |
Output is correct - L* = 40 |
9 |
Correct |
38 ms |
2312 KB |
Output is correct - L* = 40 |
10 |
Correct |
30 ms |
2436 KB |
Output is correct - L* = 40 |
11 |
Correct |
31 ms |
2324 KB |
Output is correct - L* = 40 |
12 |
Correct |
32 ms |
2292 KB |
Output is correct - L* = 40 |
13 |
Correct |
28 ms |
2404 KB |
Output is correct - L* = 40 |
14 |
Correct |
32 ms |
2240 KB |
Output is correct - L* = 40 |
15 |
Correct |
31 ms |
2228 KB |
Output is correct - L* = 40 |
16 |
Correct |
32 ms |
2396 KB |
Output is correct - L* = 40 |
17 |
Correct |
32 ms |
2320 KB |
Output is correct - L* = 40 |
18 |
Correct |
30 ms |
2232 KB |
Output is correct - L* = 40 |
19 |
Correct |
28 ms |
2264 KB |
Output is correct - L* = 40 |
20 |
Correct |
31 ms |
2356 KB |
Output is correct - L* = 40 |
21 |
Correct |
32 ms |
2320 KB |
Output is correct - L* = 40 |
22 |
Correct |
31 ms |
2232 KB |
Output is correct - L* = 40 |
23 |
Correct |
37 ms |
2300 KB |
Output is correct - L* = 40 |
24 |
Correct |
37 ms |
2196 KB |
Output is correct - L* = 40 |
25 |
Correct |
32 ms |
2248 KB |
Output is correct - L* = 40 |
26 |
Correct |
30 ms |
2244 KB |
Output is correct - L* = 40 |
27 |
Correct |
38 ms |
2340 KB |
Output is correct - L* = 40 |
28 |
Correct |
30 ms |
2236 KB |
Output is correct - L* = 40 |
29 |
Correct |
33 ms |
2232 KB |
Output is correct - L* = 40 |
30 |
Correct |
36 ms |
2276 KB |
Output is correct - L* = 40 |
31 |
Correct |
33 ms |
2344 KB |
Output is correct - L* = 40 |
32 |
Correct |
30 ms |
2344 KB |
Output is correct - L* = 40 |
33 |
Correct |
30 ms |
2248 KB |
Output is correct - L* = 40 |
34 |
Correct |
37 ms |
2288 KB |
Output is correct - L* = 40 |
35 |
Correct |
30 ms |
2232 KB |
Output is correct - L* = 40 |
36 |
Correct |
34 ms |
2252 KB |
Output is correct - L* = 40 |
37 |
Correct |
44 ms |
2264 KB |
Output is correct - L* = 40 |
38 |
Correct |
33 ms |
2308 KB |
Output is correct - L* = 40 |
39 |
Correct |
31 ms |
2228 KB |
Output is correct - L* = 40 |
40 |
Correct |
32 ms |
2248 KB |
Output is correct - L* = 40 |