text stringlengths 1 24.5M |
|---|
/* ========================================
* ZLowpass2 - ZLowpass2.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZLowpass2_H
#include "ZLowpass2.h"
#endif
void ZLowpass2::processReplacing(float **inputs, float **outputs, VstInt32 sampl... |
/* ========================================
* ZNotch - ZNotch.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch_H
#include "ZNotch.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new ZNotch(audioM... |
/* ========================================
* ZNotch - ZNotch.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch_H
#define __ZNotch_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#endif
#i... |
/* ========================================
* ZNotch - ZNotch.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch_H
#include "ZNotch.h"
#endif
void ZNotch::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
{
... |
/* ========================================
* ZNotch2 - ZNotch2.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch2_H
#include "ZNotch2.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new ZNotch2(a... |
/* ========================================
* ZNotch2 - ZNotch2.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch2_H
#define __ZNotch2_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#endif... |
/* ========================================
* ZNotch2 - ZNotch2.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZNotch2_H
#include "ZNotch2.h"
#endif
void ZNotch2::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
... |
/* ========================================
* Zoom - Zoom.h
* Copyright (c) airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __Zoom_H
#include "Zoom.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Zoom(audioMaster);}
Zoom:... |
/* ========================================
* Zoom - Zoom.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) Airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __Zoom_H
#define __Zoom_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#endif
#include <set>
#includ... |
/* ========================================
* Zoom - Zoom.h
* Copyright (c) airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __Zoom_H
#include "Zoom.h"
#endif
void Zoom::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
{
float* in1 = ... |
/* ========================================
* ZOutputStage - ZOutputStage.h
* Copyright (c) airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZOutputStage_H
#include "ZOutputStage.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {retur... |
/* ========================================
* ZOutputStage - ZOutputStage.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) Airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZOutputStage_H
#define __ZOutputStage_H
#ifndef __audioeffect__
#include "audioeffectx.h... |
/* ========================================
* ZOutputStage - ZOutputStage.h
* Copyright (c) airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZOutputStage_H
#include "ZOutputStage.h"
#endif
void ZOutputStage::processReplacing(float **inputs, float **outputs, VstI... |
/* ========================================
* ZRegion - ZRegion.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion_H
#include "ZRegion.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new ZRegion(a... |
/* ========================================
* ZRegion - ZRegion.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion_H
#define __ZRegion_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#endif... |
/* ========================================
* ZRegion - ZRegion.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion_H
#include "ZRegion.h"
#endif
void ZRegion::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
... |
/* ========================================
* ZRegion2 - ZRegion2.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion2_H
#include "ZRegion2.h"
#endif
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new ZRegi... |
/* ========================================
* ZRegion2 - ZRegion2.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion2_H
#define __ZRegion2_H
#ifndef __audioeffect__
#include "audioeffectx.h"
#e... |
/* ========================================
* ZRegion2 - ZRegion2.h
* Copyright (c) 2016 airwindows, Airwindows uses the MIT license
* ======================================== */
#ifndef __ZRegion2_H
#include "ZRegion2.h"
#endif
void ZRegion2::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram... |
#include "data.h"
FaceData::FaceData():
landmark_coords{0}
{
rotation = new double[3]{ 0,0,0 };
translation = new double[3]{ 0,0,0 };
face_coords = new int[4]{ 0,0,0,0 };
face_detected = false;
}
std::string FaceData::to_string()
{
std::string datastring =
std::string("Pitch ") + std::to_string(this->rotation... |
#pragma once
#include <string>
class FaceData
{
public:
// Yaw, Pitch, Roll
double* rotation;
// X, Y, Z
double* translation;
// Landmark positions: [[x,y], [x,y], [x,y], ...]
float landmark_coords[66 * 2];
// Crop position x0, y0, x1, y1
int* face_coords;
bool face_detected;
FaceData();
std::string ... |
#include "filters.h"
#include <cstring>
#include <cmath>
MAFilter::MAFilter(int steps, int array_size)
{
this->n_steps = steps;
this->array_size = array_size;
this->idx = 0; // this->idx < this->n_steps
this->circular_buffer = (float *)new float[steps * array_size]; // float[steps][array_size]
this->sum = (floa... |
#pragma once
class IFilter
{
public:
virtual void filter(float* in_array, float* out_array)=0;
};
class MAFilter : public IFilter
{
private:
int array_size;
int idx;
int n_steps;
float *circular_buffer;
float *sum;
public:
MAFilter(int steps, int array_size);
~MAFilter();
void filter(float* in_array, fl... |
#include "imageprocessor.h"
ImageProcessor::ImageProcessor() :
mean_scaling(0.485f, 0.456f, 0.406f),
std_scaling(0.229f, 0.224f, 0.225f)
{
//mean_scaling = mean_scaling / std_scaling;
cv::divide(mean_scaling, std_scaling, mean_scaling);
std_scaling *= 255.0f;
}
void ImageProcessor::normalize(cv::Mat& image)
{
... |
#pragma once
#include "opencv2/opencv.hpp"
class ImageProcessor
{
public:
ImageProcessor();
void normalize(cv::Mat& image);
void cvt_format(float* from, float* dest, int dim_x = 224, int dim_y = 224);
void transpose(float* from, float* dest, int dim_x = 224, int dim_y = 224);
/*
Alternative implementation of ... |
#include "model.h"
#include "_inference.h"
#include "onnxruntime_cxx_api.h"
#include "opencv2/core/matx.hpp"
#include <math.h>
#include <omp.h>
float inline logit(float p)
{
if (p >= 0.9999999f)
p = 0.9999999f;
else if (p <= 0.0000001f)
p = 0.0000001f;
p = p / (1.0f - p);
return log... |
#pragma once
#include "opencv2/opencv.hpp"
#include <onnxruntime_cxx_api.h>
#include "data.h"
#include "imageprocessor.h"
#include "PositionSolver.h"
#include "filters.h"
/**
* Struct for storing and passing around model config and other stuff
*/
struct TrackerMetadata {
// Face width ratio with respect to the stan... |
#include "PositionSolver.h"
#define USE_FOV // Use FOV correction for the camera matrix.
PositionSolver::PositionSolver(
int width,
int height,
float prior_pitch,
float prior_yaw,
float prior_distance,
bool complex,
float fov,
float x_scale,
float y_scale,
float z_scale)... |
#pragma once
#include "opencv2/core/matx.hpp"
#include "opencv2/opencv.hpp"
#include "data.h"
/**
This class is responsible of mapping 2D facial landmarks to its
corresponding 3D world coordinates for pose estimation (Position and rotation).
*/
class PositionSolver
{
public:
double prior_pitch = -2.f, prior_yaw ... |
#pragma once
#include <onnxruntime_cxx_api.h>
// This class is a workaround since, for some reason we cant have several ONNX Environments
// created. When instantiating a second one, it'll crash. With this we ensure only one is created
// and shared among models.
class SessionSingleton
{
public:
std::shared_pt... |
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Client.rc
//
#define IDB_PNG1 102
#define IDI_ICON1 103
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE ... |
// source code from https://github.com/inspirit/PS3EYEDriver
#ifndef PS3EYECAM_H
#define PS3EYECAM_H
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <memory>
// Get rid of annoying zero length structure warnings from libusb.h in MSVC
#ifdef _MSC_VER
#pragma warning(push)
#pragma w... |
#ifndef _DEBUG
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif // !_DEBUG
#include <QtWidgets/QApplication>
#include "view/WindowMain.h"
#include "presenter/presenter.h"
#include "model/Config.h"
#include <omp.h>
#include "tracker/TrackerFactory.h"
#include "spdlog/spdlog.h"
#include "spdl... |
#pragma once
#define AITRACK_VERSION "v0.7.1-alpha" |
#pragma once
#include <cstdint>
#include "CameraSettings.h"
class Camera
{
public:
int width, height, fps;
bool is_valid = false;
virtual void start_camera() = 0;
virtual void stop_camera() = 0;
virtual void get_frame(uint8_t* buffer) = 0;
virtual void set_settings(CameraSettings& settings) = 0;
virtual Camer... |
#include "CameraFactory.h"
#include "Ps3Camera.h"
#include "OCVCamera.h"
#include "NullCamera.h"
std::unique_ptr<Camera> CameraFactory::buildCamera(int width, int height, int cam_index, int exposure, int gain)
{
std::unique_ptr<Camera> camera;
bool error = false;
bool has_ps3 = true;
try
{
camera = std::make_... |
#pragma once
#include <memory>
#include <vector>
#include "Camera.h"
#include "CameraSettings.h"
class CameraFactory
{
public:
std::unique_ptr<Camera> buildCamera(int width, int height, int cam_index = 0, int exposure=-1, int gain=-1);
std::vector<std::shared_ptr<Camera>> getCameras(CameraSettings& settings);
};
|
#include "CameraSettings.h"
CameraSettings::CameraSettings()
{
exposure = -1;
gain = -1;
width = 640;
height = 480;
fps = 30;
}
CameraSettings::CameraSettings(CameraSettings& settings)
{
exposure = settings.exposure;
gain = settings.gain;
fps = settings.fps;
width = settings.width;
height = settings.height... |
#pragma once
struct CameraSettings
{
int exposure;
int gain;
int fps;
int width;
int height;
CameraSettings();
CameraSettings(CameraSettings& settings);
~CameraSettings();
};
|
#pragma once
#include "Camera.h"
class NullCamera : public Camera
{
public:
NullCamera(int width = -1, int height = -1, int fps = 0) : Camera(width, height, fps){};
~NullCamera() {};
void start_camera() {};
void stop_camera() {};
void get_frame(uint8_t* buffer) {};
void set_settings(CameraSettings& settings) {};... |
#include "OCVCamera.h"
OCVCamera::OCVCamera(int width, int height, int fps, int index) :
Camera(width, height, fps),
size(0, 0),
cap(),
cam_index(index)
{
CV_BACKEND = cv::CAP_DSHOW;
if (!is_camera_available())
{
// Check again with Media foundation backend
CV_BACKEND = cv::CAP_MSMF;
if (!is_camera_avail... |
#pragma once
#include "Camera.h"
#include "opencv2/opencv.hpp"
class OCVCamera : public Camera
{
private:
cv::VideoCapture cap;
cv::Size size;
float w_scale;
float exposure, gain;
int cam_native_height, cam_native_width, cam_native_fps;
int cam_index;
int CV_BACKEND;
bool is_camera_available();
public:
OCVC... |
#include "Ps3Camera.h"
#include <stdexcept>
#include <iostream>
Ps3Camera::Ps3Camera(int width, int height, int fps) :
Camera(width, height, fps),
ctx(width, height, fps),
setting()
{
if (!this->ctx.hasDevices() || ctx.eye == nullptr)
{
throw std::runtime_error("No PS3 Camera found.");
}
ctx.eye->setFlip(tru... |
#pragma once
#include "Camera.h"
#include <vector>
#include "ps3eye.h"
struct ps3eye_context {
ps3eye_context(int width, int height, int fps) :
eye(0)
, devices(ps3eye::PS3EYECam::getDevices())
, running(true)
, last_ticks(0)
, last_frames(0)
{
if (hasDevices()) {
// TODO: Maybe this is nullptr
ey... |
#include "Config.h"
#include <QFileInfo>
ConfigData ConfigData::getGenericConfig()
{
ConfigData conf = ConfigData();
conf.ip = "";
conf.port = 0;
conf.camera_fov = 56.0;
conf.prior_distance = .7;
conf.show_video_feed = true;
conf.selected_model = 0;
conf.selected_camera = 0;
conf.num_cameras_detected = 0;
... |
#pragma once
#include <string>
#include <QSettings>
/**
* Struct which holds both the program state and the serializable part of this
* state (aka. preferences).
*/
struct ConfigData
{
std::string ip;
int port;
int video_height;
int video_width;
int video_fps;
double prior_distance, camera_fov;
bool show_vide... |
#include <iostream>
#include "UDPSender.h"
UDPSender::UDPSender(const char* dest_ip, int dest_port)
{
this->ip = std::string(dest_ip);
this->port = dest_port;
//std::cout << "ip: " << this->ip << " port: " << this->port << std::endl;
WSAStartup(MAKEWORD(2, 2), &data);
memset(&dest_IPv6,... |
#pragma once
#include <Winsock2.h>
#include <Ws2tcpip.h>
#include <Ws2def.h>
#include <string>
/**
Data sender to Opentrack using UDP
*/
class UDPSender
{
private:
const int BUFFER_SIZE = sizeof(double) * 6;
double position_data[6];
union
{
sockaddr_in dest;
sockaddr_in6 dest_IPv6;
};
union
{
sockad... |
#include "UpdateChecker.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <iostream>
#include <QObject>
UpdateChecker::UpdateChecker(std::string& version, IUpdateSub *obs):
request(),
manager(),
current_version(version)
{
this->observer = obs;
}
void UpdateChecker::c... |
#pragma once
#include <string>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class Version
{
public:
int stage; // alpha, beta or normal
std::string ver;
Version(std::string version): ver(), stage(10)
{
int index_dash = -1;
for (int i = 0; i < version.size(); i++)
{
if (version.at(i) == *... |
#pragma once
#include "../model/Config.h"
//#include "../view/i_view.h"
class IView;
class IPresenter
{
public:
virtual void toggle_tracking() = 0;
virtual void save_prefs(const ConfigData& data) = 0;
virtual void calibrate_face(IView& view) = 0;
virtual void close_program() = 0;
}; |
#include <chrono>
#include <memory>
#include <string.h>
#include "presenter.h"
#include "opencv2/opencv.hpp"
#include "../camera/CameraFactory.h"
#include "../version.h"
#include <QThread>
#include <qapplication.h>
Presenter::Presenter(IView& view, std::unique_ptr<TrackerFactory>&& t_factory, std::unique_ptr<Confi... |
#pragma once
#include "model.h"
#include "../model/Config.h"
#include "../model/UDPSender.h"
#include "../model/UpdateChecker.h"
#include "i_presenter.h"
#include "../view/i_view.h"
#include "../camera/Camera.h"
#include "filters.h"
#include "../tracker/TrackerFactory.h"
#include "../tracker/TrackerWrapper.h"
#incl... |
#pragma once
#include "data.h"
#include "filters.h"
#include "opencv2/core/matx.hpp"
///**
//* Possible model types.
//* TRACKER_VERY_FAST = An experimental (even) faster model which runs about x2 faster than TRACKER_FAST.
//* TRACKER_FAST = Less weights. Lighter, but could have less precission
//* TRACKER_MED = Hal... |
#include "TrackerFactory.h"
#include <codecvt>
#include <locale>
#include "model.h"
#include "TrackerWrapper.h"
std::unique_ptr<TrackerWrapper> TrackerFactory::buildTracker(
int im_width,
int im_height,
float distance,
float fov,
TRACKER_TYPE type,
float x_scale,
float y_scale,
float z_scale)
{
std::str... |
#pragma once
#include "TrackerWrapper.h"
#include <string.h>
#include <memory>
#include <vector>
/**
* Builds TrackerWrapper objects which will be the ones used for making the detections.
*/
class TrackerFactory
{
private:
std::string model_dir;
public:
TrackerFactory(std::string modeldir);
std::unique_ptr<Tracke... |
#include "TrackerWrapper.h"
TrackerWrapper::TrackerWrapper(std::unique_ptr<ITracker>&& model, TRACKER_TYPE type)
{
this->model = std::move(model);
this->type = type;
}
TrackerWrapper::~TrackerWrapper()
{
this->model.reset(nullptr);
}
void TrackerWrapper::predict(cv::Mat& image, FaceData& face_data, cons... |
#pragma once
#include "ITrackerWrapper.h"
#include "model.h"
/**
* Possible model types.
* TRACKER_VERY_FAST = An experimental (even) faster model which runs about x2 faster than TRACKER_FAST.
* TRACKER_FAST = Less weights. Lighter, but could have less precission
* TRACKER_MED = Half the way. Could offer a good trad... |
/**
* This file is part of https://github.com/mitei/qglobalshortcut
* Code is provided as copy/paste solution
* Kudos to mitei :)
*/
#include "qglobalshortcut.h"
#include <QCoreApplication>
#include <QKeySequence>
#include <Windows.h>
QMultiHash<quint32, QGlobalShortcut*> QGlobalShortcut::shortcuts_;
QGlobalShortcut:... |
/**
* This file is part of https://github.com/mitei/qglobalshortcut
* Code is provided as copy/paste solution
* Kudos to mitei :)
*/
#pragma once
#include <QWidget>
#include <QObject>
#include <QMultiHash>
#include <QAbstractNativeEventFilter>
#include <QKeySequence>
class QGlobalShortcut : public QObject {
Q_OBJ... |
#include "ConfigWindow.h"
#include <string>
ConfigWindow::ConfigWindow(IRootView *prev_window, QWidget *parent)
: QWidget(parent), calibration_window((IRootView* )this)
{
ui.setupUi(this);
this->parentView = prev_window;
// References to UI objects
gp_box_camera_prefs = findChild<QGroupBox*>("gbCamera");
gp_bo... |
#pragma once
#include <QWidget>
#include <QSpinBox>
#include <QMessageBox>
#include <QLineEdit>
#include <QCheckBox>
#include "ui_ConfigWindow.h"
#include "i_view.h"
#include "HeadCalibrationWindow.h"
class ConfigWindow : public QWidget, IView
{
Q_OBJECT
public:
ConfigWindow(IRootView *prev_window, QWidget *pare... |
#include "HeadCalibrationWindow.h"
#include "ConfigWindow.h"
#include <string>
HeadCalibrationWindow::HeadCalibrationWindow(IRootView* prev_window, QWidget* parent)
: QMainWindow(parent)
{
ui.setupUi(this);
this->parentView = prev_window;
btn_calibrate = findChild<QPushButton*>("calibrateBtn");
view_frame = fi... |
#pragma once
#include <QWidget>
#include <QSpinBox>
#include <QMessageBox>
#include <QLineEdit>
#include <QCheckBox>
#include "ui_HeadCalibrationWindow.h"
#include "i_view.h"
class HeadCalibrationWindow : public QMainWindow, public IView
{
Q_OBJECT
public:
HeadCalibrationWindow(IRootView* prev_window, QWidget* p... |
#pragma once
#include "opencv2/opencv.hpp"
#include "../model/Config.h"
#include "../presenter/i_presenter.h"
enum MSG_SEVERITY { CRITICAL, NORMAL };
class IView {
public:
/**
* Registers a presenter as an observer of this view
*/
virtual void connect_presenter(IPresenter* presenter) = 0;
/**
* Show the t... |
#include "WindowMain.h"
#include "../presenter/presenter.h"
#include "../version.h"
#include <iostream>
#include <QMessageBox>
WindowMain::WindowMain(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
this->setWindowTitle(QString("AITrack %1").ar... |
#pragma once
#include "i_view.h"
#include <QtWidgets/QMainWindow>
#include <QImage>
#include "opencv2/opencv.hpp"
#include "../presenter/i_presenter.h"
#include "ui_MainWindow.h"
#include "ConfigWindow.h"
#include "../utils/qglobalshortcuts/qglobalshortcut.h"
//class IPresenter;
class WindowMain : public QMain... |
// source code from https://github.com/inspirit/PS3EYEDriver
#include "ps3eye.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include <atomic>
#if defined WIN32 || defined _WIN32 || defined WINCE
#include <windows.h>
#include <algorithm>
#ifdef __MINGW32__
void SetThreadName(const char* thr... |
// source code from https://github.com/inspirit/PS3EYEDriver
#ifndef PS3EYECAM_H
#define PS3EYECAM_H
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <memory>
// Get rid of annoying zero length structure warnings from libusb.h in MSVC
#ifdef __cplusplus
FILE iob[] = { *stdin, *stdo... |
/**
* PS3EYEDriver C API Interface
* Copyright (c) 2014 Thomas Perl <m@thp.io>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the ab... |
/**
* PS3EYEDriver C API Interface
* Copyright (c) 2014 Thomas Perl <m@thp.io>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the ab... |
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <string.h>
class BinaryIndexedTree {
public:
int n;
std::vector<int> tree;
int Lowbit(int x)
{
return x & -x;
}
int Query(int x)
{
int ans = 0;
for (int i = x; i > 0; i -= Lowbit(i)) {
an... |
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_set>
using namespace std;
// 计算kmpå‰ç¼€è¡¨ï¼Œç”¨äºŽåŒ¹é…失败åŽè¿›è¡Œå›žé€€æ“作
std::vector<int> compute_prefix_function(std::string& p)
{
int n = p.length();
... |
#include <stdio.h>
void swap(int* a, int* b)
{
int t = *a;
*a = *b;
*b = t;
}
int partition(int arr[], int low, int high)
{
int anchor = arr[high];
int i = low - 1;
for (int j = low; j <= high - 1; j++) {
if (arr[j] <= anchor) {
// æ°¸æ’ç»å…¸ï¼Œä¸€æ¬¡é历æžå®šç»•ç€é”šç‚¹åˆ... |
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
class RBTree {
private:
enum Color {
RED,
BLACK
};
enum Direction {
LEFT,
RIGHT
};
public:
... |
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#include <time.h>
class RBTree {
private:
enum Color {
RED,
BLACK
};
enum Direction {
LEFT,
RIGHT
};
public:
struct RBTreeNode {
int k = 0;
int v = 0;
... |
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
// @lc code=start
class NumArray {
public:
struct TreeNode{
int l, r, v;
TreeNode * left = nullptr;
TreeNode * right = nullptr;
TreeNode(int l, int r, int v):l(l), r(r), v(v){
}... |
#include<bits/stdc++.h>
using namespace std;
int n,p1,p2,p3,t1,t2;
int l,r,s,ans=0;
int main()
{
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&l,&r);
if(i>1)
{
ans=ans+min(t1,l-s)*p1;
if(l-s>t1)
{
ans=an... |
#include <bits/stdc++.h>
using namespace std;
int n,a[200005],b[10];
int main()
{
cin>>n;
for(int i=1;i<=n;i++) scanf("%1d",&a[i]);
for(int i=1;i<=9;i++) scanf("%d",&b[i]);
for(int i=1;i<=n;i++)
{
if(a[i]<b[a[i]])
{
for(int j=i;a[j]<=b[a[j]]&&j<=n;j++) a[j]=b[a[j]];
break;
}
}
for(int i=1;i<=n;i... |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
cout<<(bool)(abs(a+c-b*2)%3)<<'\n';
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int t;
long long x,n,res;
int main()
{#include<bits/stdc++.h>
using namespace std;
int t;
int alphabeta[30];
char a;
string s;
int ans=0;
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getcha... |
#include<bits/stdc++.h>
using namespace std;
int t;
long long x,n,res;
int main()
{
cin>>t;
while(t--)
{
cin>>x>>n;
res=x;
for(long long i=n/4*4+1;i<=n;i++)
{
if(res%2) res+=i;
else res-=i;
}
cout<<res<<endl;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
const long long inf=0x3f3f3f3f3f3f3f3f;
long long n,a[200001],sum=0,mx=-inf;
int main()
{
long long t;
scanf("%lld",&t);
while(t--)
{
sum=0,mx=-inf;
scanf("%lld",&n);
for(long long i=1;i<=n;++i) scanf("%lld",&a[i]);
sort(a+1,a+1+n);
for(long long i=1;i<=n;+... |
#include<bits/stdc++.h>
using namespace std;
int T;
int n,a[200005];
char s[200005];
bool cmp(int x,int y)
{
return x>y;
}
int main()
{
scanf("%d",&T);
begin:
while(T--)
{
vector<int> blue,red;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
cin>>s+1;
for(int i=1;i<=n;i++)
{
... |
#include<bits/stdc++.h>
using namespace std;
int T;
int n,m;
string a;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
cin>>a;
int x=0,y=0,xmax=0,xmin=0,ymax=0,ymin=0;
for(int i=0;i<a.size();++i)
{
switch(a[i])
{
case 'L': --y; break;
case 'R': ++y; break;
case 'D': ++x... |
#include<iostream>
using namespace std;
int n,t,a;
int main()
{
scanf("%d%d",&n,&t);
for(int i=1;i<=n;i++)
{
scanf("%d",&a);
t-=(86400-a);
if(t<=0)
{
cout<<i;
return 0;
}
}
return 0;
}
|
#include<iostream>
using namespace std;
long long n,m,a;
int main()
{
cin>>n>>m>>a;
cout<<((n-1)/a+1)*((m-1)/a+1);
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
char s[]="1001010111001010";
int main()
{
int n;
cin>>n;
cout<<s[n-1];
return 0;
}
|
#include<iostream>
#include<cstring>
using namespace std;
int main(){
char s1[505]={0},s2[505]={0};
int n1[505]={0},n2[505]={0},ans[505]={0};
cin>>s1>>s2;
int l1=strlen(s1);
int l2=strlen(s2);
for(int i=0;i<l1;i++)
{
n1[i]=s1[l1-i-1]-'0';
}
for(int i=0;i<l2;i++)
{
n2[i]=s2[l2-i-1... |
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n;
cin>>n;
if(n==2) cout<<"NO"<<endl;
else if(n%2==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[10001];
int ans = 0, sum = 0;
int main()
{
while (gets(a))
{
if (a[0] == '+')
{
sum++;
}
else if (a[0] == '-')
{
sum--;
}
else
{
for (int i = 0; i < strlen(a); i++)
{
if (a[i] == ':')
{
ans += (strlen(a) - i - 1) * sum;
... |
#include <bits/stdc++.h>
using namespace std;
int a[5];
int main()
{
for(int i=1;i<=4;i++) cin>>a[i];
sort(a+1,a+5);
if(a[1]+a[2]>a[3]||a[2]+a[3]>a[4]) cout<<"TRIANGLE"<<endl;
else if(a[1]+a[2]==a[3]||a[2]+a[3]==a[4]) cout<<"SEGMENT"<<endl;
else cout<<"IMPOSSIBLE"<<endl;
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string a;
int i;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a;
if(a.length()>10)
{
cout<<a[0]<<a.length()-2<<a[a.length()-1]<<endl;
}
else
{
cout<<a<<endl;
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
cin>>n>>k;
for(int x=1;x<=n;x++)
{
if(x*(x+1)*2.5+k>240)
{
cout<<x-1;
return 0;
}
}
cout<<n;
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int iIn1,iIn2,iIn3,iIn4;
int main()
{
cin>>iIn1>>iIn2>>iIn3>>iIn4;
cout<<(((iIn1^iIn2)&(iIn3|iIn4))^((iIn2&iIn3)|(iIn1^iIn4)));
return 0;
}
|
#include<iostream>
#include<cstring>
using namespace std;
string s;
int n;
int ans=0;
int main()
{
cin>>n;
while(n--)
{
cin>>s;
if(s[0]=='T')//Tetrahedron
{
ans+=4;
}
if(s[0]=='C')//Cube
{
ans+=6;
}
if(s[0]=='O')... |
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
long long x,y;
int kzo(int a,int b)
{
if(b==0)
{
x=1;
y=0;
return a;
}
long long tmp=kzo(b,a%b);
long long t=x;
x=y;
y=(t-a/b*y);
return tmp;
}
int main()
{
scanf("%lld%lld%lld",&a,&b,&c);
c=-c;
long long d=kzo(a,b);
if(c%d!=0)
{
pr... |
#include<bits/stdc++.h>
using namespace std;
int n,k;
int num=0;
int a[3005];
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1,a+1+n);
for(int i=1;i<=k;i++)
{
num+=a[i];
}
cout<<num;
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
map<string,bool>k;
int n;
string a;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a;
k[a]?cout<<"YES\n":cout<<"NO\n";
k[a]=1;//ÒòΪmapµÄ³õʼֵΪ¿Õ£¬ËùÒÔ¿ÉÒÔÖ±½ÓÅжÏ
}
return 0;
}
|
#include<iostream>
using namespace std;
int n,t,a;
int main()
{
scanf("%d%d",&n,&t);
for(int i=1;i<=n;i++)
{
scanf("%d",&a);
t-=(86400-a);
if(t<=0)
{
cout<<i;
return 0;
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.