# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
133249 | dantoh000 | 즐거운 사진 수집 (JOI13_collecting) | C++14 | 1536 ms | 61944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,q;
struct node{
int h;
vector<int> a;
vector<int> ct;
node(int _h){
h = _h;
a = vector<int>((1<<(n+1))+1,0);
ct = vector<int>(n+1,0);
}
void up(int x){
int cur = n-1;
x += (1<<n)-1;
a[x] ^= 1;
x >>= 1;
while (x){
if (a[x] == 2) ct[cur]--;
//printf("%d depends %d %d\n",x,a[x<<1],a[(x<<1)+1]);
if (a[x<<1] == a[(x<<1) + 1]) a[x] = a[x<<1];
else a[x] = 2;
if (a[x] == 2) ct[cur]++;
x >>= 1;
cur--;
}
}
}*rx, *ry;
int main(){
scanf("%d%d",&n,&q);
rx = new node(n), ry = new node(n);
for (int i = 0; i < q; i++){
int a, b;
scanf("%d%d",&a,&b);
if (a == 0){
rx->up(b);
}
else ry->up(b);
long long ans = 0;
for (int i = 0; i < n; i++){
//printf("size %d %lld\n",i,-1ll*rx->ct[i]*ry->ct[i]+(1ll<<i)*(rx->ct[i]+ry->ct[i]));
ans -= 1ll*rx->ct[i]*ry->ct[i]-(1ll<<i)*(rx->ct[i]+ry->ct[i]);
}
printf("%lld\n",(ans<<2) + 1);
}
}
컴파일 시 표준 에러 (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... |