Skip to content

Instantly share code, notes, and snippets.

View yarrr-ru's full-sized avatar

Safronov Aleksei yarrr-ru

View GitHub Profile
@yarrr-ru
yarrr-ru / interstellar.cpp
Created April 15, 2016 13:01
Deadline24, Interstellar, 86.40
#include "game.h"
#include "geometry.h"
#include <queue>
#include <array>
#include <set>
#include <cstdlib>
constexpr size_t kNone = std::numeric_limits<size_t>::max();
constexpr double kEps = 1e-5;
constexpr size_t kProfitTurnsAfterReset = 10;
@yarrr-ru
yarrr-ru / cf_marathon_r2.cpp
Created July 31, 2018 12:38
Codeforces Marathon Round 2 yarrr's final submit
#pragma GCC optimize("Ofast,no-stack-protector,tree-vectorize")
#pragma GCC target("avx,sse4,tune=native")
#include <iostream>
#include <cassert>
#include <string>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
x1=-1.0; x2=+1.0; y1=-1.5; y2=+4.5; z1=-1.0; z2=+1.0;
nx=7; ny=9; nz=5;
step_x=(x2-x1)/(nx-1); step_y=(y2-y1)/(ny-1); step_z=(z2-z1)/(nz-1);
step_min = min([step_x step_y step_z]);
[x,y,z]=meshgrid([x1:step_x:x2], [y1:step_y:y2], [z1:step_z:z2]);
f= 4.*x+x.^2.*y-z.*y;
isosurface(x,y,z,f), title('PS. Press<enter>');
pause;
close;
x1=-1.0; x2=+1.0; y1=-1.5; y2=+4.5;
nx=7; ny=9;
step_x=(x2-x1)/(nx-1); step_y=(y2-y1)/(ny-1);
step_min = min(step_x,step_y);
[x,y]=meshgrid([x1:step_x:x2], [y1:step_y:y2]);
z= x.^3 + 5.*x.^2.*y + x - y.^3;
surf(x,y,z), title('PS. Press<enter>');
pause;
xx=reshape(x,1,nx*ny);
yy=reshape(y,1,nx*ny);