Skip to content

Instantly share code, notes, and snippets.

View fpdjsns's full-sized avatar
😄
인생의 풍류를 즐기는 중

withham fpdjsns

😄
인생의 풍류를 즐기는 중
View GitHub Profile
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
//
// Created by fpdjsns
// Copyright © 2019 fpdjsns. All rights reserved.
//
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
@fpdjsns
fpdjsns / Pony Express.cpp
Last active March 4, 2019 12:56
[Round 1B 2017] Problem C. Pony Express : https://code.google.com/codejam/contest/8294486/dashboard#s=p2&a=2 Floyd–Warshall
//
// Created by fpdjsns
// Copyright © 2019 fpdjsns. All rights reserved.
//
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define INF 1e12
typedef long long LL;
class Solution {
public:
int longestOnes(vector<int>& A, int K) {
int answer = 0;
queue<int> zeroQ;
int start = 0;
for(int end=0;end<A.size();end++){
if(A[end] == 0)
zeroQ.push(end);
if(!zeroQ.empty() && zeroQ.size() > K){
//
// Created by fpdjsns
// Copyright © 2019 fpdjsns. All rights reserved.
//
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
class Solution {
public:
int findJudge(int N, vector<vector<int>>& trust) {
vector<int> cnt(N+1, 0);
for(int i=0;i<trust.size();i++){
int from = trust[i][0];
int to = trust[i][1];
cnt[to]++;
cnt[from] = -N; // The town judge trusts nobody.
}
@fpdjsns
fpdjsns / Cruise Control.cpp
Created February 17, 2019 12:03
[Round 1B 2017] Problem A. Steed 2: Cruise Control : https://code.google.com/codejam/contest/8294486/dashboard
//
// Created by fpdjsns
// Copyright © 2019 fpdjsns. All rights reserved.
//
/*
* 시간복잡도 : O(N)
*/
#include<iostream>
class Solution {
private:
const int EMPTY = 0;
const int FRESH = 1;
const int ROTTEN = 2;
struct Cell {
int x;
int y;
int minutes;
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {