답안 #951226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951226 2024-03-21T12:30:14 Z PM1 Bitwise (BOI06_bitwise) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define ll long long ll
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:6:10: error: expected initializer before 'mxn'
    6 | const ll mxn=105;
      |          ^~~
bitwise.cpp:7:4: error: expected initializer before 'n'
    7 | ll n,p,cnt[mxn],ans=0;
      |    ^
bitwise.cpp:8:18: error: wrong number of template arguments (1, should be 2)
    8 | vector<pair<ll,ll>>v[mxn];
      |                  ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bitwise.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
  211 |     struct pair
      |            ^~~~
bitwise.cpp:8:25: error: template argument 1 is invalid
    8 | vector<pair<ll,ll>>v[mxn];
      |                         ^
bitwise.cpp:8:25: error: template argument 2 is invalid
bitwise.cpp: In function 'int main()':
bitwise.cpp:10:7: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 |  cin>>n>>p;
      |       ^
      |       yn
bitwise.cpp:10:10: error: 'p' was not declared in this scope
   10 |  cin>>n>>p;
      |          ^
bitwise.cpp:11:9: error: expected ';' before 'i'
   11 |  for(ll i=1;i<=p;i++)
      |         ^
bitwise.cpp:11:9: error: 'i' was not declared in this scope
bitwise.cpp:11:17: error: expected ')' before ';' token
   11 |  for(ll i=1;i<=p;i++)
      |     ~           ^
      |                 )
bitwise.cpp:11:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   11 |  for(ll i=1;i<=p;i++)
      |  ^~~
bitwise.cpp:11:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   11 |  for(ll i=1;i<=p;i++)
      |                  ^
bitwise.cpp:5:22: warning: unused variable 'll' [-Wunused-variable]
    5 | #define ll long long ll
      |                      ^~
bitwise.cpp:11:6: note: in expansion of macro 'll'
   11 |  for(ll i=1;i<=p;i++)
      |      ^~
bitwise.cpp:11:18: error: 'i' was not declared in this scope
   11 |  for(ll i=1;i<=p;i++)
      |                  ^
bitwise.cpp:13:9: error: expected ';' before 'i'
   13 |  for(ll i=1;i<=p;i++){
      |         ^
bitwise.cpp:13:17: error: expected ')' before ';' token
   13 |  for(ll i=1;i<=p;i++){
      |     ~           ^
      |                 )
bitwise.cpp:13:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |  for(ll i=1;i<=p;i++){
      |  ^~~
bitwise.cpp:13:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   13 |  for(ll i=1;i<=p;i++){
      |                  ^
bitwise.cpp:5:22: warning: unused variable 'll' [-Wunused-variable]
    5 | #define ll long long ll
      |                      ^~
bitwise.cpp:13:6: note: in expansion of macro 'll'
   13 |  for(ll i=1;i<=p;i++){
      |      ^~
bitwise.cpp:20:9: error: expected ';' before 'k'
   20 |  for(ll k=31;k>=0;k--){
      |         ^
bitwise.cpp:20:9: error: 'k' was not declared in this scope
bitwise.cpp:20:18: error: expected ')' before ';' token
   20 |  for(ll k=31;k>=0;k--){
      |     ~            ^
      |                  )
bitwise.cpp:20:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   20 |  for(ll k=31;k>=0;k--){
      |  ^~~
bitwise.cpp:20:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   20 |  for(ll k=31;k>=0;k--){
      |                   ^
bitwise.cpp:5:22: warning: unused variable 'll' [-Wunused-variable]
    5 | #define ll long long ll
      |                      ^~
bitwise.cpp:20:6: note: in expansion of macro 'll'
   20 |  for(ll k=31;k>=0;k--){
      |      ^~
bitwise.cpp:20:19: error: 'k' was not declared in this scope
   20 |  for(ll k=31;k>=0;k--){
      |                   ^
bitwise.cpp:67:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   67 |  cout<<ans;
      |        ^~~
      |        abs