Submission #821110

#TimeUsernameProblemLanguageResultExecution timeMemory
821110PVM_pvmMarshmallow Molecules (CCO19_day2problem2)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 5007 int n,m; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; bitset<n> gr[n]; for (int q=0;q<m;q++) { int a,b; cin>>a>>b; gr[a][b]=1; } long long ans=0; for (int q=1;q<=n;q++) { ans+=gr[q].count(); while(true) { int pos=gr[q]._Find_first(); if (pos==gr[q].size()) break; gr[q][pos]=0; gr[pos]=gr[pos]|gr[q]; } } cout<<ans<<"\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:13: error: the value of 'n' is not usable in a constant expression
   11 |     bitset<n> gr[n];
      |             ^
Main.cpp:4:5: note: 'int n' is not const
    4 | int n,m;
      |     ^
Main.cpp:11:13: note: in template argument for type 'long unsigned int'
   11 |     bitset<n> gr[n];
      |             ^
Main.cpp:16:14: error: invalid types 'int[int]' for array subscript
   16 |         gr[a][b]=1;
      |              ^
Main.cpp:21:20: error: request for member 'count' in 'gr[q]', which is of non-class type 'int'
   21 |         ans+=gr[q].count();
      |                    ^~~~~
Main.cpp:24:27: error: request for member '_Find_first' in 'gr[q]', which is of non-class type 'int'
   24 |             int pos=gr[q]._Find_first();
      |                           ^~~~~~~~~~~
Main.cpp:25:28: error: request for member 'size' in 'gr[q]', which is of non-class type 'int'
   25 |             if (pos==gr[q].size()) break;
      |                            ^~~~
Main.cpp:26:18: error: invalid types 'int[int]' for array subscript
   26 |             gr[q][pos]=0;
      |                  ^