private bool GetResult3(ref Result3 result) { if (null == myJobManager3) { return false; } ICogRecord tmpRecord; ICogRecord topRecord; try { topRecord = myJobManager3.UserResult(); if (null == topRecord) { return false; } if (null != cogRecordDisplay3) { tmpRecord = topRecord.SubRecords["ShowLastRunRecordForUserQueue"]; tmpRecord = tmpRecord.SubRecords["LastRun"]; tmpRecord = tmpRecord.SubRecords["CogFixtureTool1.OutputImage"]; if (null != tmpRecord.Content) { cogRecordDisplay3.Record = tmpRecord; } cogRecordDisplay3.AutoFit = true; } return true; } catch { return false; } }
public async Task <IActionResult> Edit(int id, [Bind("id,organization,account,service_key,short_description,long_description,service_display_name,service_url,language,created_at,updated_at")] Result3 result3) { if (id != result3.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(result3); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Result3Exists(result3.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(result3)); }
public async Task <IActionResult> Create([Bind("id,organization,account,service_key,short_description,long_description,service_display_name,service_url,language,created_at,updated_at")] Result3 result3) { if (ModelState.IsValid) { _context.Add(result3); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(result3)); }
/* * Determina la localidad con mayor cantidad de homicidios en cualquier * intervalo de K dias y devuelve esa localidad, la cantidad de homicidios * y el intervalo de K dias. En caso de empates, puedes devolver cualquier * intervalo que contega ese maximo y cualquier localidad con la maxima * cantidad de homicidios. */ static Result3 MostFrequentLocationInAnyKDayInterval(Event[] events, int K) { // TODO: implementar algoritmo que resuelva este problema e indique cual // es su complejidad average case // Para simplificar, puedes asumir que el dia maximo es D = 10000 // Complejidad esperada: mejor que O((N-K)*K) // Valor: 8 puntos // Documentacion de Dictionary : https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.dictionary-2?view=netframework-4.7.2 // Documentacion : TrygetValue https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.dictionary-2.trygetvalue?view=netframework-4.7.2 // Operaciones utilizadas: Trygetvalue, remove; son O(1) y add O(1) avg if (events.Length == 0) { throw new InvalidOperationException(); // O(1) } Dictionary <string, Interfrecuencia> ord = new Dictionary <string, Interfrecuencia>(); // Crearlo es constante int MaxFrecuencia = 0, day = 0; // O(1) string location = string.Empty; // O(1) for (int i = 0; i < events.Length; i++) // O(N) { if (events[i].day < 0) // Si el numero es negativo simplemente lo saltara porque no existen dias negativos { continue; // O(1) } bool flag = false; // O(1) flag = ord.TryGetValue(events[i].location, out Interfrecuencia a); // O(1) if (ord.Count == 0) { Interfrecuencia z = new Interfrecuencia(1, events[i].day); // O(1) ord.Add(events[i].location, z); // O(1) avg MaxFrecuencia = 1; // O(1) location = events[i].location; // O(1) day = events[i].day; // O(1) } else if (flag) { if (events[i].day >= a.day && events[i].day < a.day + K) { a.count++; // O(1) if (a.count >= MaxFrecuencia) { MaxFrecuencia = a.count; // O(1) location = events[i].location; // O(1) day = a.day; // O(1) } ord.Remove(events[i].location); // O(1) ord.Add(events[i].location, a); // O(1) } else { Interfrecuencia Z = new Interfrecuencia(1, events[i].day); // O(1) ord.Remove(events[i].location); // O(1) ord.Add(events[i].location, Z); // O(1) } } else { Interfrecuencia Z = new Interfrecuencia(1, events[i].day); //O(1) ord.Add(events[i].location, Z); // O(1) } } int number = day + K - 1; // O(1) Result3 var = new Result3(day, number, location, MaxFrecuencia); // O(1) return(var); // Mi complejidad en el avg case es O(N) lineal }
/* * Determina la localidad con mayor cantidad de homicidios en cualquier * intervalo de K dias y devuelve esa localidad, la cantidad de homicidios * y el intervalo de K dias. En caso de empates, puedes devolver cualquier * intervalo que contega ese maximo y cualquier localidad con la maxima * cantidad de homicidios. */ static Result3 MostFrequentLocationInAnyKDayInterval(Event[] events, int K) { // TODO: implementar algoritmo que resuelva este problema e indique cual // es su complejidad average case // Para simplificar, puedes asumir que el dia maximo es D = 10000 // Complejidad esperada: mejor que O((N-K)*K) // Valor: 8 puntos // Documentacion de Dictionary : https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.dictionary-2?view=netframework-4.7.2 // Documentacion : TrygetValue https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.dictionary-2.trygetvalue?view=netframework-4.7.2 // Operaciones utilizadas: Trygetvalue, remove; son O(1) y add O(1) avg // Documentacion de LinkedList: https://docs.microsoft.com/es-es/dotnet/api/system.collections.generic.linkedlist-1?view=netframework-4.7.2 // Operaciones utilizadas: RemoveFirst, AddLast, Count, son O(1) if (events.Length == 0) { throw new InvalidOperationException(); // O(1) } Dictionary <string, int> ord = new Dictionary <string, int>(); // Crearlo es constante LinkedList <Event> locaciones = new LinkedList <Event>(); // Crearlo es Constante int MaxFrecuencia = 0, day = 0; // O(1) string location = string.Empty; // O(1) for (int i = 0; i < events.Length; i++) // O(N) { if (events[i].day < 0) // Si el numero es negativo simplemente lo saltara porque no existen dias negativos { continue; // O(1) } bool flag = false; // O(1) flag = ord.TryGetValue(events[i].location, out int a); // O(1) if (ord.Count == 0) { locaciones.AddLast(events[i]); // O(1) ord.Add(events[i].location, 1); // O(1) avg MaxFrecuencia = 1; // O(1) location = events[i].location; // O(1) day = events[i].day; // O(1) } else if (flag) { if (events[i].day >= locaciones.First.Value.day && events[i].day < locaciones.First.Value.day + K) { a++; // O(1) if (a >= MaxFrecuencia) { MaxFrecuencia = a; // O(1) location = events[i].location; // O(1) day = events[i].day; // O(1) } ord.Remove(events[i].location); // O(1) ord.Add(events[i].location, a); // O(1) locaciones.AddLast(events[i]); // O(1) } else { string tmp = locaciones.First.Value.location; // O(1) locaciones.RemoveFirst(); // O(1) ord.TryGetValue(tmp, out int value); // O(1) if (value > 1) { value--; // O(1) } ord.Remove(tmp); // O(1) ord.Add(tmp, value); // O(1) AVG i--; // O(1) } } else { if (events[i].day >= locaciones.First.Value.day && events[i].day < locaciones.First.Value.day + K) { locaciones.AddLast(events[i]); //O(1) ord.Add(events[i].location, 1); // O(1) } else { string tmp = locaciones.First.Value.location; // O(1) ord.Remove(tmp); // O(1) locaciones.RemoveFirst(); // O(1) i--; // O(1) } } } int number = day - K + 1; // O(1) if (number < 0) { number = 0; // O(1) } if (day < K) { day = K; // O(1) } Result3 var = new Result3(number, day, location, MaxFrecuencia); // O(1) return(var); // Mi complejidad en el avg case es O(N) lineal }
public void Run(Result1 res1, Result2 res2, Result3 res3) => Interlocked.Add(ref _result, res1.Data + res2.Data + res3.Data);