Submission #717219

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7172192023-04-01 14:54:54Obada_SalehBeads and wires (APIO14_beads)C++14
0 / 100
4 ms5076 KiB
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<long long,int>>adj[200010];
long long dp1[200010],dp2[200010],dp3[200010],dp4[200010];
bool comp(pair<long long,int>x,pair<long long,int>y)
{
return x.first+dp3[x.second]-dp4[x.second]>y.first+dp3[y.second]-dp4[y.second];
}
void dfs(int node=1,int p=0)
{
for(int i=0;i<adj[node].size();i++)
{
int neighbour=adj[node][i].second;
if(neighbour==p)
{
adj[node].erase(adj[node].begin()+i);
break;
}
}
for(int i=0;i<adj[node].size();i++)
{
int neighbour=adj[node][i].second;
dfs(neighbour,node);
}
for(int i=0;i<adj[node].size();i++)
{
long long weight=adj[node][i].first;
int neighbour=adj[node][i].second;
dp4[neighbour]=dp3[neighbour];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

beads.cpp: In function 'void dfs(int, int)':
beads.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<adj[node].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
beads.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0;i<adj[node].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
beads.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<adj[node].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
beads.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=1;i<adj[node].size();i++)
      |                     ~^~~~~~~~~~~~~~~~~
beads.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int i=2;i<adj[node].size();i++)
      |                     ~^~~~~~~~~~~~~~~~~
beads.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<adj[node].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
beads.cpp:66:19: warning: unused variable 'weight' [-Wunused-variable]
   66 |         long long weight=adj[node][i].first;
      |                   ^~~~~~
beads.cpp: In function 'int main()':
beads.cpp:75:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |     freopen("beads.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
beads.cpp:76:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |     freopen("beads.out","r",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...