제출 #758767

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
7587672023-06-15 09:09:55keta_tsimakuridzePastiri (COI20_pastiri)C++14
100 / 100
620 ms94744 KiB
#include<bits/stdc++.h>
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
const int N = 5e5 + 5, mod = 1e9 + 7; // !
int n, d[N];
vector<int> V[N], A;
struct node {
int A, B, ans;
} x[N];
void dfs(int u, int p) {
for(int i = 0; i < V[u].size(); i++) {
int v = V[u][i];
if(v == p) continue;
dfs(v, u);
if(x[v].A + 1 > d[u]) {
x[v].ans++; A.push_back(v);
// cout << "++" << v << endl;
x[v].A = -n;
x[v].B = d[v];
}
x[u].A = max(x[u].A, x[v].A + 1);
x[u].B = max(x[u].B, x[v].B - 1);
x[u].ans += x[v].ans;
}
if(x[u].A <= x[u].B) x[u].A = -n - 5;
if(d[u] == 0 && x[u].B < 0) x[u].A = max(x[u].A, 0);
// cout << u <<" " << x[u].A << " " << x[u].B << " " << x[u].ans << endl;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

컴파일 시 표준 에러 (stderr) 메시지

pastiri.cpp: In function 'void dfs(int, int)':
pastiri.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < V[u].size(); i++) {
      |                    ~~^~~~~~~~~~~~~
pastiri.cpp: At global scope:
pastiri.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
pastiri.cpp: In function 'int main()':
pastiri.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int i = 0; i < V[u].size(); i++) {
      |                        ~~^~~~~~~~~~~~~
pastiri.cpp:60:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int i = 0; i < A.size(); i++) cout << A[i] << " "; cout << endl;
      |                    ~~^~~~~~~~~~
pastiri.cpp:60:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   60 |     for(int i = 0; i < A.size(); i++) cout << A[i] << " "; cout << endl;
      |     ^~~
pastiri.cpp:60:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   60 |     for(int i = 0; i < A.size(); i++) cout << A[i] << " "; cout << endl;
      |                                                            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...