Pagini recente » Borderou de evaluare (job #694601) | Borderou de evaluare (job #1219126) | Borderou de evaluare (job #943989) | Borderou de evaluare (job #1890585) | Borderou de evaluare (job #3003845)
Borderou de evaluare (job #3003845)
Raport evaluator
Compilare:
main.cpp: In function 'int main()':
main.cpp:2:936: warning: 'er' may be used uninitialized in this function [-Wmaybe-uninitialized]
2 | using namespace std;fstream f("concurs.in",ios::in),g("concurs.out",ios::out);int p[35002],tin[35002],tout[35002],t[35002][16],n,m,x,y,root,c,curt;vector<int>adj[35002];void dfs(int x){tin[x]=++curt;for(auto y:adj[x])dfs(y);tout[x]=++curt;}bool is_ancestor(int x, int y){return (tin[x] <= tin[y] && tout[y] <= tout[x]);}int lca(int x, int y){if (is_ancestor(x, y))return x;if (is_ancestor(y, x))return y;for (int i = 15; i >= 0; i--)if (!is_ancestor(t[x][i], y))x = t[x][i];return t[x][0];}int main(){f >> n >> m;for (int i = 1; i <= n; i++)f >> p[i];for (int i = 2; i <= n; i++){f >> x >> y;t[y][0] = x;adj[x].push_back(y);}for (int i = 1; i <= n; i++)if (!t[i][0])root = i;for (int j = 1; j <= 15; j++)for (int i = 1; i <= n; i++){t[i][j] = t[t[i][j - 1]][j - 1];if(!t[i][j])t[i][j]=root;}dfs(root);int an=0,sw,er;while(m--){f>>x>>y;int c=p[lca(x,y)];if(an<c||(an==c&&x<sw)||(an==c&&x==sw&&y<er))an=c,sw=x,er=y;}g<<an<<' '<<sw<<' '<<er;}
| ^~
main.cpp:2:931: warning: 'sw' may be used uninitialized in this function [-Wmaybe-uninitialized]
2 | using namespace std;fstream f("concurs.in",ios::in),g("concurs.out",ios::out);int p[35002],tin[35002],tout[35002],t[35002][16],n,m,x,y,root,c,curt;vector<int>adj[35002];void dfs(int x){tin[x]=++curt;for(auto y:adj[x])dfs(y);tout[x]=++curt;}bool is_ancestor(int x, int y){return (tin[x] <= tin[y] && tout[y] <= tout[x]);}int lca(int x, int y){if (is_ancestor(x, y))return x;if (is_ancestor(y, x))return y;for (int i = 15; i >= 0; i--)if (!is_ancestor(t[x][i], y))x = t[x][i];return t[x][0];}int main(){f >> n >> m;for (int i = 1; i <= n; i++)f >> p[i];for (int i = 2; i <= n; i++){f >> x >> y;t[y][0] = x;adj[x].push_back(y);}for (int i = 1; i <= n; i++)if (!t[i][0])root = i;for (int j = 1; j <= 15; j++)for (int i = 1; i <= n; i++){t[i][j] = t[t[i][j - 1]][j - 1];if(!t[i][j])t[i][j]=root;}dfs(root);int an=0,sw,er;while(m--){f>>x>>y;int c=p[lca(x,y)];if(an<c||(an==c&&x<sw)||(an==c&&x==sw&&y<er))an=c,sw=x,er=y;}g<<an<<' '<<sw<<' '<<er;}
| ^~~
Test |
Timp executie |
Memorie folosita |
Mesaj |
Punctaj/test |
1 | 0ms | 184kb | OK | 10 |
2 | 0ms | 184kb | OK | 10 |
3 | 0ms | 184kb | OK | 10 |
4 | 0ms | 184kb | OK | 10 |
5 | 0ms | 184kb | OK | 10 |
6 | 5ms | 1888kb | OK | 10 |
7 | 102ms | 5296kb | OK | 10 |
8 | 13ms | 2936kb | OK | 10 |
9 | 127ms | 3796kb | OK | 10 |
10 | 189ms | 3878kb | OK | 10 |
Punctaj total | 100 |