제출 #476982

#제출 시각아이디문제언어결과실행 시간메모리
476982nicolaalexandraAmusement Park (JOI17_amusement_park)C++14
0 / 100
7 ms1144 KiB
#include <bits/stdc++.h> #include "Joi.h" #define DIM 1010 using namespace std; static vector <int> L[DIM]; static int viz[DIM],val[DIM],idx,n; /*void MessageBoard (int x, int y){ return; } */ void dfs (int nod){ viz[nod] = 1; val[nod] = (++idx) % 60; /// ce bit ii atribui for (auto vecin : L[nod]) if (!viz[vecin]) dfs (vecin); } void Joi (int _n, int m, int a[], int b[], long long x, int useless){ n = _n; for (int i=0;i<m;i++){ a[i]++, b[i]++; L[a[i]].push_back(b[i]); L[b[i]].push_back(a[i]); } memset (viz,0,sizeof viz); memset (val,0,sizeof val); idx = -1; dfs (1); for (int i=1;i<=n;i++){ int bit = val[i]; if (x & (1LL<<bit)) MessageBoard(i-1,1); else MessageBoard(i-1,0); } } /* int main (){ ifstream cin ("date.in"); ofstream cout ("date.out"); int n,m,x,i,a[100],b[100]; cin>>n>>m>>x; for (i=0;i<m;i++) cin>>a[i]>>b[i]; Joi(n,m,a,b,x,1); for (i=1;i<=n;i++) cout<<val[i]; return 0; }*/
#include <bits/stdc++.h> #include "Ioi.h" #define DIM 1010 using namespace std; static vector <int> L[DIM],edg[DIM]; static int viz[DIM],val[DIM],fth[DIM],s[DIM],f[70],idx,n,cnt; /*int Move (int dest){ //return value[dest+1]; } */ void add_edge (int x, int y){ edg[x].push_back(y); edg[y].push_back(x); } void dfs (int nod){ viz[nod] = s[nod] = 1; val[nod] = (++idx) % 60; /// ce bit ii atribui for (auto vecin : L[nod]) if (!viz[vecin]){ fth[vecin] = nod; add_edge (nod,vecin); dfs (vecin); s[nod] += s[vecin]; } } void dfs2 (int nod, int tata){ if (cnt == 60) return; for (auto vecin : edg[nod]) if (vecin != tata){ int ans = Move(vecin); if (f[val[vecin]] == -1) cnt++; f[val[vecin]] = ans; if (cnt == 60) return; dfs2 (vecin,nod); if (cnt == 60) return; Move(nod); /// trb sa ma intorc inapoi } } long long Ioi (int n, int m, int a[], int b[], int start, int val_start, int useless){ for (int i=0;i<m;i++){ L[a[i]].push_back(b[i]); L[b[i]].push_back(a[i]); } //memset (viz,0,sizeof viz); //memset (val,0,sizeof val); idx = -1; dfs (0); fth[0] = -1; memset (f,-1,sizeof f); cnt = 0; if (f[val[start]] == -1){ f[val[start]] = val_start; cnt = 1; } while (s[start] < 60){ start = fth[start]; int ans = Move(start); if (f[val[start]] == -1){ f[val[start]] = ans; cnt++; } } dfs2 (start,fth[start]); long long sol = 0; for (int i=0;i<60;i++) if (f[i]) sol += (1LL<<i); return sol; } /*int main (){ ifstream cin ("date.in"); ofstream cout ("date.out"); return 0; }*/

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

Ioi.cpp:8:56: warning: 'n' defined but not used [-Wunused-variable]
    8 | static int viz[DIM],val[DIM],fth[DIM],s[DIM],f[70],idx,n,cnt;
      |                                                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...