답안 #198875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198875 2020-01-27T23:40:35 Z imaxblue Bitwise (BOI06_bitwise) C++17
35 / 100
7 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
#define startrng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, c, p[105], a[105], x[105], y[105], x2[105], y2[105], ans;
bool done[105];
bool run(int B){
  drain(done);
  fox(l, n){
    x2[l]=x[l];
    y2[l]=y[l];
  }
  //cout << "*" << B << endl;
  for (int l=30; l>=B; --l){
    if (((1<<l)&ans)==0 && l!=B) continue;
    fox(l2, k){
      if (done[l2]) continue;
      bool tmp=0;
      for (int l3 = p[l2]; l3 < p[l2]+a[l2]; ++l3){
        if (x2[l3] >= (1<<l)/* && ((1<<l+1)>x2[l3])*/){
          tmp = 1;
          x2[l3] -= (1<<l);
          y2[l3] -= (1<<l);
        }
      }
      //cout << l << ' ' << tmp << ' ' << p[l2] << ' ' << x2[p[l2]+1] << ":";
      //cout << y2[p[l2]] << ' ';
      for (int l3 = p[l2]; l3 < p[l2]+a[l2]; ++l3){
        if (x2[l3] < (1<<l) && y2[l3] >= (1<<l)){
          if (tmp){
            done[l2] = 1;
            break;
          }
          y2[l3] -= (1<<l);
          x2[l3] -= (1<<l);
          tmp = 1;
        }
      }
      //if (done[l2] == 1)
      if (!tmp) return 0;
    }
  }
  return 1;
}
int32_t main(){
  scanf("%i%i", &n, &k);
  fox(l, k){
    scanf("%i", a+l);
    p[l+1]=a[l]+p[l];
  }
  fox(l, n) scanf("%i%i", x+l, y+l);
  foxr(l, 31){
    if (run(l)) ans += (1<<l);
    //cout << endl;
  }
  cout << ans;
  return 0;
}

/*
4 2
2 2
1 8
1 1
2 8
2 4
*/

Compilation message

bitwise.cpp: In function 'int32_t main()':
bitwise.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i%i", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~
bitwise.cpp:79:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i", a+l);
     ~~~~~^~~~~~~~~~~
bitwise.cpp:82:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fox(l, n) scanf("%i%i", x+l, y+l);
             ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Correct 5 ms 256 KB Output is correct
5 Incorrect 7 ms 256 KB Output isn't correct
6 Incorrect 5 ms 256 KB Output isn't correct
7 Incorrect 5 ms 256 KB Output isn't correct
8 Correct 5 ms 256 KB Output is correct
9 Incorrect 5 ms 256 KB Output isn't correct
10 Correct 5 ms 376 KB Output is correct
11 Incorrect 5 ms 256 KB Output isn't correct
12 Correct 5 ms 256 KB Output is correct
13 Incorrect 5 ms 256 KB Output isn't correct
14 Incorrect 5 ms 256 KB Output isn't correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Incorrect 5 ms 256 KB Output isn't correct
18 Incorrect 5 ms 256 KB Output isn't correct
19 Incorrect 5 ms 376 KB Output isn't correct
20 Incorrect 5 ms 256 KB Output isn't correct