Submission #879205

# Submission time Handle Problem Language Result Execution time Memory
879205 2023-11-26T21:34:28 Z goduadzesaba Closing Time (IOI23_closing) C++17
8 / 100
121 ms 35368 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
long long u[200005],d[400005],i,j,ds,m,ans,sm;
vector <pair<long long,long long> > v[200005];
void dfs(long long g){
	u[g]=1;
	for (int j=0; j<v[g].size(); j++)
		if (u[v[g][j].first]==0){
			m++; ds+=v[g][j].second; d[m]=ds;
			dfs(v[g][j].first); ds-=v[g][j].second;
		}
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W){
    for (i=0; i<N; i++){u[i]=0; v[i].clear();}
    for (i=0; i<N-1; i++){
    	v[U[i]].push_back({V[i],W[i]});
    	v[V[i]].push_back({U[i],W[i]});
	}
	ds=m=d[0]=0; dfs(X);
	for (i=0; i<N; i++) u[i]=0;
	m++; ds=d[m]=0; dfs(Y);
	sort (d,d+m+1);
	ans=sm=0;
	for (i=0; i<m && sm+d[i]<=K; i++){
		sm+=d[i]; ans++;
	}
	return ans;
}

Compilation message

closing.cpp: In function 'void dfs(long long int)':
closing.cpp:8:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int j=0; j<v[g].size(); j++)
      |                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 119 ms 31492 KB Output is correct
2 Correct 121 ms 35368 KB Output is correct
3 Correct 64 ms 13840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Incorrect 2 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Incorrect 2 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Incorrect 2 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8796 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -