# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
821061 | PVM_pvm | Marshmallow Molecules (CCO19_day2problem2) | C++17 | 1520 ms | 3412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define MAXN 5007
bitset<MAXN> gr[MAXN];
int n,m;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |