Submission #951227

# Submission time Handle Problem Language Result Execution time Memory
951227 2024-03-21T12:30:52 Z PM1 Bitwise (BOI06_bitwise) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define ll long long int
const ll mxn=105;
ll n,p,cnt[mxn],ans=0;
vector<pair<ll,ll>>v[mxn];
int main(){
	cin>>n>>p;
	for(ll i=1;i<=p;i++)
		cin>>cnt[i];
	for(ll i=1;i<=p;i++){
		while(cnt[i]--){
			ll a,b;
			cin>>a>>b;
			v[i].push_back({a,b});
		}
	}
	for(ll k=31;k>=0;k--){
		
		bool t=1;
		for(ll i=1;i<=p;i++){
			ll g=0,gg=0;
			for(auto j:v[i]){
				//cout<<j.fr<<" "<<j.sc<<'\n';
				if(j.fr>=(1<<k) && j.sc>=(1<<k))g++;
				else if(j.sc>=(1<<k))gg++;
			}
			if(g+gg==0){
				t=0;
				break;
			}
		}
		if(!t)
			continue;
		else{
			ans+=(1<<k);
			for(ll i=1;i<=p;i++){
				ll g=0,gg=0;
				for(auto j:v[i]){
					if(j.fr>=(1<<k) && j.sc>=(1<<k))g++;
					else if(j.sc>=(1<<k))gg++;
				}
				if(g){
					for(ll j=0;j<v[i].size();j++){
						auto y=v[i][j];
						if(y.fr>=(1<<k) && y.sc>=(1<<k)){
							v[i][j].fr-=(1<<k);
							v[i][j].sc-=(1<<k);
						}
					}
				}
				else{
					for(ll j=0;j<v[i].size();j++){
						auto y=v[i][j];
						if(y.fr<(1<<k) && y.sc>=(1<<k)){
							v[i][j].fr-=(1<<k);
							v[i][j].sc-=(1<<k);
							break;
						}
					}
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Compilation message

bitwise.cpp: In function 'int main()':
bitwise.cpp:46:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |      for(ll j=0;j<v[i].size();j++){
      |                 ~^~~~~~~~~~~~
bitwise.cpp:55:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |      for(ll j=0;j<v[i].size();j++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 1 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 1 ms 348 KB Output isn't correct
19 Incorrect 1 ms 344 KB Output isn't correct
20 Incorrect 1 ms 348 KB Output isn't correct