Last active
May 12, 2016 04:09
-
-
Save tjkendev/0ea618bf838f3b1f1774 to your computer and use it in GitHub Desktop.
Code Festival 2015 決勝問題 - submit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s,t,u = map(len,raw_input().split()) | |
print "valid" if s==5 and t==7 and u==5 else "invalid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = input() | |
if n==1: | |
print 1 | |
else: | |
print int(7*n/2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = input() | |
s = raw_input() | |
st = [] | |
i = 0 | |
ans = 0 | |
while i<2*n: | |
if i < 2*n-1 and (s[i:i+2] == "10" or s[i:i+2] == "01"): | |
i += 2 | |
continue | |
if len(st)>0 and st[-1] == s[i]: | |
st.pop() | |
else: | |
st.append("1" if s[i]=="0" else "0") | |
ans += 1 | |
i += 1 | |
print ans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<string> | |
#include<vector> | |
#include<queue> | |
#include<stack> | |
#include<map> | |
#include<set> | |
#include<algorithm> | |
#include<functional> | |
#include<cstdio> | |
#include<cstdlib> | |
#include<cmath> | |
using namespace std; | |
#define mind(a,b) (a>b?b:a) | |
#define maxd(a,b) (a>b?a:b) | |
#define absd(x) (x<0?-(x):x) | |
#define pow2(x) ((x)*(x)) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=0; --i) | |
#define repl(i,s,n) for(int i=s; i<=n; ++i) | |
#define replr(i,s,n) for(int i=n; i>=s; --i) | |
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j) | |
#define repe(e,obj) for(auto e : obj) | |
#define SP << " " << | |
#define COL << " : " << | |
#define COM << ", " << | |
#define ARR << " -> " << | |
#define PNT(STR) cout << STR << endl | |
#define POS(X,Y) "(" << X << ", " << Y << ")" | |
#define DEB(A) " (" << #A << ") " << A | |
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl | |
#define ALL(V) (V).begin(), (V).end() | |
#define INF 1000000007 | |
#define INFLL 10000000000000000007LL | |
#define EPS 1e-9 | |
typedef unsigned int uint; | |
typedef unsigned long ulong; | |
typedef unsigned long long ull; | |
typedef long long ll; | |
typedef long double ld; | |
typedef pair<int, int> P; | |
//typedef pair<ll, ll> P; | |
typedef pair<P, int> PI; | |
typedef pair<int, P> IP; | |
typedef pair<P, P> PP; | |
typedef priority_queue<P, vector<P>, greater<P> > pvqueue; | |
int main() { | |
// タスクの終了を管理するために使う | |
// (終了時間, id) | |
pvqueue task_q; | |
// workerをポイントの高い順に割り当てるために使う | |
// (ポイント, id) | |
priority_queue<P> que; | |
// ワーカー | |
vector<int> worker; | |
int n; | |
cin >> n; | |
vector<P> p; | |
rep(i, n) { | |
int s, t; | |
cin >> s >> t; | |
p.push_back(P(s, t)); | |
} | |
sort(ALL(p)); | |
rep(i, n) { | |
P pe = p[i]; | |
while(!task_q.empty()) { | |
P e = task_q.top(); | |
if(e.first <= pe.first) { | |
task_q.pop(); | |
int id = e.second; | |
que.push(P(worker[id], id)); | |
} else break; | |
} | |
if(que.empty()) { | |
worker.push_back(1); | |
task_q.push(P(pe.second, worker.size()-1)); | |
} else { | |
P e = que.top(); que.pop(); | |
worker[e.second] += 1; | |
task_q.push(P(pe.second, e.second)); | |
} | |
} | |
sort(ALL(worker)); | |
cout << (worker[0]==1 ? worker.size()-1 : worker.size()) << endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ['-', '!'] | |
ch = "-!" | |
state_to = [[1, 2], [0, 2], [3, 4], [2, 4], [5, 2], [4, 2]] | |
ans = ["", "-", "!", "-!", "!!", "-!!"] | |
s = raw_input() | |
state = 0 | |
for c in reversed(s): | |
state = state_to[state][ch.index(c)] | |
print ans[state] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment