QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499565#6730. CoolbitsssmyCompile Error//C++201.5kb2024-07-31 15:46:302024-07-31 15:46:30

Judging History

你现在查看的是最新测评结果

  • [2024-07-31 15:46:30]
  • 评测
  • [2024-07-31 15:46:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int T, n;
int l[N], r[N],c[N], select[N];
int solve(){
   cin>>n;
   int min1=143322333;
    for (int i = 1; i <= n; ++i){
         cin>>l[i]>>r[i];
         select[i] = 0;
         if(min1>r[i])
            min1=r[i];
    }
    int mm;
    for(int i=1;i<=31;i++){
        if((1<<i)>=min1)
            mm=i;
    }
    int ans = 0;
    for (int i = mm+1; i >= 0; --i) {
//
//        if((1<<(i+1))<min1){
//            cout<<ans<<endl;
//            return 0;
//        }
        int flag = 1;
        for (int j = 1; j <= n && flag; ++j) {
            int minn = select[j] | (1 << i);
            int maxx = select[j] | ((1 << i+1) - 1);
            if (minn > r[j] || maxx < l[j])
            flag = 0;
        }
        if (flag) {
            for (int j = 1; j <= n; ++j)
                select[j] |= 1 << i;
            ans |= 1 << i;
        }
        else {
            for (int j = 1; j <= n; ++j) {
                int minn = select[j] | (1 << i);
                int maxx = select[j] | ((1 << i+1) - 1);
                    if (minn <= r[j] && maxx >= l[j] && minn - 1 <= l[j])
                        select[j] |= 1 << i;
            }
//             if (minn <= r[j] && maxx >= l[j] && minn - 1 <= l[j])
//             ans &= ((1 << i)-1);
        }

    }
   cout<<ans<<endl;
}
int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while (T--) {
    solve();
    }

    return 0;
}

Details

answer.code:5:30: error: ‘int select [100005]’ redeclared as different kind of entity
    5 | int l[N], r[N],c[N], select[N];
      |                              ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/sys/select.h:101:12: note: previous declaration ‘int select(int, fd_set*, fd_set*, fd_set*, timeval*)’
  101 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
answer.code: In function ‘int solve()’:
answer.code:11:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   11 |          select[i] = 0;
      |                  ^
answer.code:11:20: error: assignment of read-only location ‘*(select + ((sizetype)i))’
   11 |          select[i] = 0;
      |          ~~~~~~~~~~^~~
answer.code:29:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |             int minn = select[j] | (1 << i);
      |                                ^
answer.code:29:34: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   29 |             int minn = select[j] | (1 << i);
      |                        ~~~~~~~~~ ^ ~~~~~~~~
      |                                |      |
      |                                |      int
      |                                int(int, fd_set*, fd_set*, fd_set*, timeval*)
answer.code:30:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |             int maxx = select[j] | ((1 << i+1) - 1);
      |                                ^
answer.code:30:34: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   30 |             int maxx = select[j] | ((1 << i+1) - 1);
      |                        ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
      |                                |               |
      |                                |               int
      |                                int(int, fd_set*, fd_set*, fd_set*, timeval*)
answer.code:36:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   36 |                 select[j] |= 1 << i;
      |                         ^
answer.code:36:27: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   36 |                 select[j] |= 1 << i;
      |                 ~~~~~~~~~~^~~~~~~~~
answer.code:36:27: note:   in evaluation of ‘operator|=(int(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*), int)’
answer.code:41:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |                 int minn = select[j] | (1 << i);
      |                                    ^
answer.code:41:38: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   41 |                 int minn = select[j] | (1 << i);
      |                            ~~~~~~~~~ ^ ~~~~~~~~
      |                                    |      |
      |                                    |      int
      |                                    int(int, fd_set*, fd_set*, fd_set*, timeval*)
answer.code:42:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |                 int maxx = select[j] | ((1 << i+1) - 1);
      |                                    ^
answer.code:42:38: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   42 |                 int maxx = select[j] | ((1 << i+1) - 1);
      |                            ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
      |                                    |               |
      |                                    |               int
      |                                    int(int, fd_set*, fd_set*, fd_set*, timeval*)
answer.code:44:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |                         select[j] |= 1 << i;
      |                                 ^
answer.code:44:35: error: invalid operands of types ‘int(int, fd_set*, fd_set*, fd_set*, timeval*)’ and ‘int’ to binary ‘operator|’
   44 |                         select[j] |= 1 << i;
      |                         ~~~~~~~~~~^~~~~~~~~
answer.code:44:35: note:   in evaluation of ‘operator|=(int(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*), int)’
answer.code:52:1: warning: no return statement in function returning non-void [-Wreturn-type]
   52 | }
      | ^