User Tools

Site Tools


rosedu:cdl:marius-dragus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rosedu:cdl:marius-dragus [2010/03/27 10:16]
mdragus
rosedu:cdl:marius-dragus [2020/07/20 09:16] (current)
Line 1: Line 1:
-Marius Dragus =  +Shidfar Hodizoda =  
-*Nume complet: Dragus Marius Ioan +  * Nume complet: Shidfar Hodizoda 
-*Alias-uri: DMI +  * Alias-uri: Dragus Marius Ioan 
-*Data/locul nașterii: 14 octombrie 1990,Cluj-Napoca +  * Data/locul nașterii: 14 octombrie 1990,Cluj-Napoca 
-== Educatie ==+ 
 +===== Educatie =====
  *2005-2009 Liceul International de informatica Bucuresti  *2005-2009 Liceul International de informatica Bucuresti
  *2009-prezent Universitatea Politehnica Bucuresti  *2009-prezent Universitatea Politehnica Bucuresti
  
-== Competente == +===== Competente ===== 
-*sunt smecher ce sa mai....+  * sunt smecher ce sa mai....
  
-== Link-uri spre alti oameni smecheri ==+===== Link-uri spre alti oameni smecheri =====
 [[rosedu:cdl:mircea-ghideu|Mircea Ghideu]] [[rosedu:cdl:mircea-ghideu|Mircea Ghideu]]
  
 [[rosedu:cdl:george-mitra|Mitra M. George-Daniel]] [[rosedu:cdl:george-mitra|Mitra M. George-Daniel]]
- 
 ==Acum niste cod baby== ==Acum niste cod baby==
 <code>#include<stdio.h> <code>#include<stdio.h>
-#include<assert.h> +  - include<assert.h> 
-#include<vector> +  include<vector> 
-#include<algorithm> +  include<algorithm> 
-#define pb push_back +  define pb push_back 
-#define mkp make_pair+  define mkp make_pair
  
 using namespace std; using namespace std;
Line 45: Line 45:
         }         }
  return false;  return false;
-} 
- 
-bool ver(vector<pair<short,short> > v1,short timp) 
-{ 
- sort(v1.begin(),v1.end(),cmpf); 
-        MOVE = 0; 
- for(int i = v1.size() - 1;v1.size();) 
- { 
-                if (timp < 0) return false; 
- if (timp < D[v1[i].first][v1[i].second]) return false; 
- if (timp > D[v1[i].first][v1[i].second]) 
- { 
- if (!MOVE) MOVE = v1[i].first;  
- v1.pop_back();--i; 
- timp--; 
- continue; 
- } 
- if (timp == D[v1[i].first][v1[i].second]) 
- { 
- if(!MOVE) MOVE = M[v1[i].first][v1[i].second]; 
- v1[i].second++; 
- timp--; 
-                        while(i != 0 && cmpf(v1[i],v1[i - 1])) swap(v1[i],v1[i - 1]); 
- //sort(v1.begin(),v1.end(),cmpf); 
- continue; 
- } 
- } 
-        if (timp < 0) return false; 
- return true;  
-} 
- 
-void solve(vector<pair<short,short> > &v) 
-{ 
-        if (v.size() == 0) {COST = 0;return;} 
- short x = 0,p; 
-        for(p = 1;p < N; p <<= 1); 
- for(;p;p >>= 1) 
- if (!ver(v,x + p)) 
- { 
- x += p;  
- } 
- x++; 
- ver(v,x); 
- COST = x; 
-} 
- 
-void dfs(int nod) 
-{ 
- if (VER[nod]) return ; 
- VER[nod] = 1; 
- for(int i = 0;i < (int)VECT[nod].size(); ++i) 
- { 
-                if (!VER[VECT[nod][i]]) TATA[VECT[nod][i]] = nod; 
- dfs(VECT[nod][i]);  
- } 
- VEC.clear(); 
- for(int i = 0;i < (int)VECT[nod].size(); ++i) 
- { 
- if (VER[VECT[nod][i]] == 2)VEC.pb(mkp(VECT[nod][i],0));  
- } 
- for(int i = 0;i < N && VEC.size() > 0;++i) 
- { 
- solve(VEC); 
- D[nod][i] = COST; 
- M[nod][i] = MOVE; 
- for(int i = 0;i < (int)VEC.size(); ++i) 
- { 
- if (VEC[i].first == MOVE) 
- { 
- VEC[i] = VEC[VEC.size() - 1]; 
- VEC.pop_back(); 
- } 
- if (M[VEC[i].first][VEC[i].second] == MOVE) VEC[i].second += 1;  
- } 
- } 
- VER[nod] = 2; 
-} 
- 
-int main() 
-{ 
- freopen("optic.in","r",stdin); 
- freopen("optic.out","w",stdout); 
- scanf("%d\n",&N); 
- for(int i = 1;i < N; ++i) 
- { 
- short x,y; 
- scanf("%hd %hd\n",&x,&y); 
-                assert(x != 0 && y != 0); 
- VECT[x].pb(y); 
- VECT[y].pb(x); 
- } 
- dfs(1); 
- 
-        memset(VER,0,sizeof(VER)); 
- printf("%d\n",D[1][0]); 
-        ANS.pb(mkp(1,0)); 
-        VER[1] = 1; 
-        for(int i = 1;i <= D[1][0]; ++i) 
-        { 
- 
-                AUX.clear(); 
-                for(int j = 0;j < ANS.size(); ++j) 
-                { 
-                        if (VER[M[ANS[j].first][ANS[j].second]] == 0 && M[ANS[j].first][ANS[j].second]) 
-                        { 
-                                AUX.pb(mkp(ANS[j].first,M[ANS[j].first][ANS[j].second])); 
-                                VER[M[ANS[j].first][ANS[j].second]] = 1; 
-                                ANS[j].second++; 
-                        } 
-                } 
-                printf("%d\n",AUX.size()); 
-                for(int j = 0;j < AUX.size(); ++j) 
-                { 
-                        printf("%d %d\n",AUX[j].first,AUX[j].second); 
-                        NRT = 0; 
-                        int nod = AUX[j].second; 
-                        for(NRT;VER[M[nod][NRT]];++NRT); 
-                        ANS.pb(mkp(AUX[j].second,NRT)); 
-                } 
-        } 
- 
- return 0; 
 } }
  
Line 176: Line 54:
 |caca  |maca|nata| |caca  |maca|nata|
 |gata|cu|rimele| |gata|cu|rimele|
- 
- 
rosedu/cdl/marius-dragus.1269677785.txt.gz · Last modified: 2010/03/27 10:16 by mdragus