3502 - "X network"

Problems from Southe Western Europe regional contest

Moderator: Board moderators

3502 - "X network"

Postby serur » Tue Dec 26, 2006 7:29 am

Hi fellows!

3502 - "The Mysterious X Network" - classical BFS, as it seems, but MLE.
Considering timings in its ranklist it's a tough question (best is ~2 sec), so I need some hints.

Thank you.
No rest with the wicked
serur
Experienced poster
 
Posts: 70
Joined: Thu Feb 23, 2006 10:30 pm

Re: 3502 - "X network"

Postby helloneo » Tue Dec 26, 2006 7:35 am

serur wrote:Hi fellows!

3502 - "The Mysterious X Network" - classical BFS, as it seems, but MLE.
Considering timings in its ranklist it's a tough question (best is ~2 sec), so I need some hints.

Thank you.


I did the same thing and got AC..
I use the adj list.. and nothing special..
helloneo
Experienced poster
 
Posts: 48
Joined: Mon Jul 04, 2005 5:30 am
Location: Seoul, Korea

Re: 3502 - "X network"

Postby julekmen » Mon Jan 15, 2007 1:00 pm

serur wrote:Hi fellows!

3502 - "The Mysterious X Network" - classical BFS, as it seems, but MLE.
Considering timings in its ranklist it's a tough question (best is ~2 sec), so I need some hints.

Thank you.

MLE is "memory limit"? It seems, that memory limit for this exercise is 32 MB, and if you allocate statically 100000*100*4b, it's 40mb. So you have to allocate it dynamically. The time is so long, because... the tests are big :P
julekmen
New poster
 
Posts: 6
Joined: Sun Dec 10, 2006 12:29 pm

Postby serur » Mon Jan 15, 2007 11:23 pm

Hi julekmen.

I got RTE this time with this code:

[code][/code]


It also occured to me before reading your post that dynamically allocated memory have something to do this my problem - in Pascal it was always so, for instance - so thanks.

Btw, welcome to Live Archive Community!

serur
Last edited by serur on Tue Jan 16, 2007 9:04 pm, edited 1 time in total.
No rest with the wicked
serur
Experienced poster
 
Posts: 70
Joined: Thu Feb 23, 2006 10:30 pm

Postby serur » Tue Jan 16, 2007 3:49 am

Well, fellows, it may seem ridiculous, but I got nothing but RTE, MLE.
It's a little bit disappointing to be thwarted in so "easy" a question.
What about this code:

Code: Select all


This one gives MLE
Last edited by serur on Tue Jan 16, 2007 9:04 pm, edited 1 time in total.
No rest with the wicked
serur
Experienced poster
 
Posts: 70
Joined: Thu Feb 23, 2006 10:30 pm

Postby julekmen » Tue Jan 16, 2007 5:49 pm

Hi,
you should learn STL and use C++ - your programs will be much shorter ;) You use strange low-level things, and this causes, that your code is difficult to read. I still can't see, if you are alocating memory dynamically or statically. Also, if there are many tests, memory from the last test should be used in the next test (or the mount of memory used will grow). You have nice IFDEF checking if there is a code is compiled on onlne judge - I will use it ;)

My code is (the macros on the top aren't mostly used)
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <cmath>
#include <queue>
using namespace std;
typedef long long LL; typedef vector<int> VI; typedef pair<int,int> PI;
typedef vector<PI>VPI; typedef set<int>SI; typedef map<int,int>MI;
typedef queue<int> QI;
const int INF = 2100000000;
#define PRNUM(zm) printf("%d\n",zm)
#define NL() printf("\n")
#define MAX(zm1,zm2) (zm1>=zm2 ? zm1 : zm2)
#define MIN(zm1,zm2) (zm1<=zm2 ? zm1 : zm2)
#define FOREACH(zm,r_kont,kont) for(r_kont::iterator (zm)=(kont).begin();(zm)!=(kont).end();++(zm))
#define REP(zm,m) for(int licznikmax=(m),(zm)=0;(zm)<licznikmax;++(zm))
#define FOR(zm,start,m) for(int licznikmax=(m),(zm)=(start);(zm)<=licznikmax;++(zm))
#define FORD(zm,m) for(int (zm)=m;(zm)>=0;--(zm))
#define ALL(zm) zm.begin(),zm.end()
int Zest,N1,M1,K1,L1,L2,L3;

const int IleL=100010;
vector<int>V[IleL];
int B[IleL];


int main(int argc, char* argv[])
{
   freopen("pl.txt","r",stdin);
   scanf("%d",&Zest);
   FOR(ZNR,1,Zest)
   {
      scanf("%d",&L1);
      REP(a,L1)
      {
      //   V[a].clear();
         scanf("%d",&N1);
         scanf("%d",&N1);
         V[a].resize(N1);
         vector<int> &VG=V[a];
         REP(b,N1)
         {
            scanf("%d",&L2);
            VG[b]=L2;
         }
      }
      scanf("%d %d",&N1,&M1);
      REP(a,L1)
         B[a]=INF;
      QI K;
      K.push(N1);
      B[N1]=0;
      while(!K.empty())
      {
         int NN=K.front();
         K.pop();
         int Odl=B[NN];
         vector<int> &VG=V[NN];
         REP(a,VG.size())
         {
            int NrP=VG[a];
            if(B[NrP]>Odl+1)
            {
                B[NrP]=Odl+1;
                K.push(NrP);
            }
         }
      }
      printf("%d %d %d",N1,M1,B[M1]-1);
      if(ZNR!=Zest)
         printf("\n");
   }
   return 0;
}
//---------------------------------------------------------------------------
julekmen
New poster
 
Posts: 6
Joined: Sun Dec 10, 2006 12:29 pm

Postby serur » Thu Jan 18, 2007 8:08 pm

Hi julekmen,
sorry for a delay in answering, I was just busy here...
Well, thank you for STL advice, but you see - I'm just learning data structure desing, so it makes more sense to me to go on handicrafting like this, although Board gurus don't recommend me it.

Keep posting,
serur
No rest with the wicked
serur
Experienced poster
 
Posts: 70
Joined: Thu Feb 23, 2006 10:30 pm

Re: 3502 - "X network"

Postby waitkleider » Thu Mar 22, 2012 3:35 am

Many in Bezug auf zits hochzeitskleid empire kann tatsächlich schaden und auch reizen Pickel / Akne. Sie sollten sich bewusst sein, einige Arten abendkleid satin der Behandlung kann in der chiffon brautkleider Tat könnten Sie Ihre Poren und die Haut noch viel schlimmer im Vergleich zu bisherigen Therapien lila abendkleid zu cure.Natural machen sind oft cocktailkleider rosa sehr beachtenswert und auch leistungsfähige Ansätze zur Behandlung Pickel dauerhaft. Ihr Körper benötigt nur zeitweise Ernährung brautjungfernkleider Harmonie neben natual Haut care.Try diese abendkleider kurz günstig Tipps hier im Folgenden aufgeführt, um Akneausbrüche mit natürlichen Mitteln zu stoppen. Sie sind ziemlich ballkleider günstig geradlinig, dennoch sehr effektiv, wenn durch hochzeitskleider mit schleppe die Art und Weise of.1 gefolgt. Sie sollten bleiben hydratisiert, haben Sie immer und hörte abendkleid schwarz lang über das Sie zumindest Acht hochzeitskleid tüll Becher Wasser von Tag zu Tag einnehmen müssen. Der Körper verlangt viel von H2O und halten abendkleid aus spitze den Körper zusätzlich zu blumenmädchenkleid 2012 der Epidermis gereinigt zusätzlich zu nahrhaft. Viel mehr zwingend notwendig, dass Sie viel Wasser zu trinken für abendkleider kurz diejenigen, die Pickel issues.2 abendkleider chiffon haben. Was auch immer Sie sich entscheiden zu tun, stellen Sie sicher, wählen Sie nicht, die Begining, abendkleider lila drücken oder vielleicht fühlen abendkleid asymmetrisch sich die Mitesser oder gar Standorten seit dies zu erreichen ist wahrscheinlich, um die spezifische Situation mehr brautkleider organza schmerzhaft. Es könnte sein, mini brautkleid doch wirklich attraktiv, sollten Sie sich berühren Sie nicht die betroffenen Stelle als auch das Halten und abendkleider tüll den Kauf benötigen erweitert, abendkleid lila um der Lage sein, sich zu erholen zusammen mit erschreckenden Ursache auf der skin.3. Fertiggerichten, die reich neckholder brautkleider im Zinkoxid während Zink brautkleid wadenlang ist ein antibakterielles repräsentativ und ist auch wichtiges Element des skin4. Bemühen Sie sich um Dinge wie ballkleid lang Chrom in Ihrer Ernährung abendkleider bremen jeden Tag zählen, ist Chrom perfekt
waitkleider
New poster
 
Posts: 10
Joined: Thu Mar 22, 2012 3:29 am

fake sunglasses

Postby ardyhikl » Thu Jun 28, 2012 11:29 am

Discussing shades replica sunglasses wholesale the len's elements, this must be mentioned which they fluctuate a lot : a lot of them are more substantial, although some are definitely tough. A common Cheap Fake Oakley Cycling Sunglasses applied for sunglass the len's is also the adhering to:Polycarbonate can be a type of tough compact plastic. Another type of plastic : Fake Oakley Ducati Sunglasses : is mainly applied for prescription-grade the len's. Glass is incredibly tough although serious.Your sun shades cheap designer sunglasses when using the CE make adhere to most requirements and directives, and still provide sufficient ultraviolet ray safeguards for your little brown eyes.
ardyhikl
New poster
 
Posts: 10
Joined: Thu Jun 28, 2012 9:12 am


Return to South Western

Who is online

Users browsing this forum: No registered users and 1 guest

cron