Last active
May 12, 2016 04:10
-
-
Save tjkendev/3f8bd2f458395743c812 to your computer and use it in GitHub Desktop.
Code Thanks Festival A日程 各問題の提出ソース(A~FはAC, GはWAしたもの)
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
a, b = map(int, raw_input().split()) | |
print a*4 + b*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
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
int main() { | |
int n, a[3]; | |
cin >> n >> a[0] >> a[1] >> a[2]; | |
sort(a, a+3); | |
int ccc = 0, c = 2, ans = 0; | |
while(ccc < n) { | |
ccc += a[c]; | |
c = (c - 1 + 3)%3; | |
++ans; | |
} | |
cout << ans << 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
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
#define N 103 | |
int main() { | |
int n, m, p[N], s, ans = 0; | |
cin >> n >> m; | |
rep(i, n) cin >> p[i]; | |
rep(i, m) { | |
cin >> s; --s; | |
ans += p[s]; | |
} | |
cout << ans << 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
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
#define N 100007 | |
int main() { | |
int n, q; | |
cin >> n >> q; | |
rep(i, q) { | |
int a, b, s, t, ans; | |
cin >> a >> b >> s >> t; | |
if(s <= a && b <= t) { | |
ans = 100*((t-s)-(b-a)); | |
}else if(a <= s && t <= b) { | |
ans = 0; | |
}else if(s <= b && b <= t) { | |
ans = 100*(t-b); | |
}else if(s <= a && a <= t) { | |
ans = 100*(a-s); | |
}else { | |
ans = 100*(t-s); | |
} | |
cout << ans << 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
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
#define N 5007 | |
#define R 53 | |
#define C 53 | |
int main() { | |
int r, c, m, n; | |
int rm[2][N], cm[2][N]; | |
int st[R][C]; | |
cin >> r >> c >> m >> n; | |
rep(i, r) rep(j, c) st[i][j] = 0; | |
rep(i, n) { | |
cin >> rm[0][i] >> rm[1][i] >> cm[0][i] >> cm[1][i]; | |
rm[0][i]--; rm[1][i]--; | |
cm[0][i]--; cm[1][i]--; | |
repl(u, rm[0][i], rm[1][i]) { | |
repl(v, cm[0][i], cm[1][i]) { | |
st[u][v] = (st[u][v] + 1)%4; | |
} | |
} | |
} | |
int count = 0; | |
rep(i, r) { | |
rep(j, c) { | |
if(st[i][j] == 0) ++count; | |
} | |
} | |
rep(i, n) { | |
int tcnt = count; | |
repl(u, rm[0][i], rm[1][i]) { | |
repl(v, cm[0][i], cm[1][i]) { | |
int tmp = st[u][v]; | |
if(tmp == 0) --tcnt; | |
tmp = (tmp - 1 + 4)%4; | |
if(tmp == 0) ++tcnt; | |
} | |
} | |
if(tcnt == m) { | |
cout << i+1 << 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
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
typedef vector<int> Graph; | |
#define N 51 | |
Graph g[N]; | |
int main() { | |
int n, m, rev[N]; | |
cin >> n >> m; | |
rep(i, n) rev[i] = 0; | |
rep(i, m) { | |
int a, b; | |
cin >> a >> b; --a; --b; | |
g[b].push_back(a); | |
} | |
queue<int> que; | |
int ans = 0; | |
bool used[N]; | |
rep(i, n) used[i] = false; | |
que.push(0); | |
used[0] = true; | |
while(!que.empty()) { | |
int v = que.front(); que.pop(); | |
++ans; | |
rep(i, g[v].size()) { | |
int u = g[v][i]; | |
if(!used[u]) { | |
que.push(u); | |
used[u] = true; | |
} | |
} | |
} | |
cout << ans << 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
// dfs解法(WA) | |
// (最後の出力を printf("%.8f\n", ans); にするとAC) | |
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
#define N 103 | |
#define K 206 | |
int n, k, p[N]; | |
bool memo[K]; | |
double ans; | |
void dfs(int c, double prob) { | |
if(c==n) { | |
int count = 0; | |
rep(i, k) { | |
if(!memo[i+1]) { | |
++count; | |
} | |
} | |
ans += prob*count; | |
return; | |
} | |
if(p[c]!=0) { | |
rep(i, k) { | |
if(!memo[i+1]) { | |
memo[i+1] = true; | |
dfs(c+1, prob*(double)p[c]/100.0); | |
memo[i+1] = false; | |
break; | |
} | |
} | |
} | |
if(p[c]!=100) { | |
rep(i, k) { | |
if(!memo[i] && !memo[i+1] && !memo[i+2]) { | |
memo[i+1] = true; | |
dfs(c+1, prob*(double)(100-p[c])/100.0); | |
memo[i+1] = false; | |
break; | |
} | |
if(i==k-1) { | |
dfs(c+1, prob*(double)(100-p[c])/100.0); | |
} | |
} | |
} | |
} | |
int main() { | |
cin >> n >> k; | |
rep(i, n) cin >> p[i]; | |
rep(i, K) memo[i] = false; | |
ans = 0.0; | |
dfs(0, 1.0); | |
cout << ans << 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
// dp解法(WA) | |
// (最後の出力を printf("%.8f\n", ans); にするとAC) | |
#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 min(a,b) (a>b?b:a) | |
//#define max(a,b) (a>b?a:b) | |
#define rep(i,n) for(int i=0; i<n; ++i) | |
#define repr(i,n) for(int i=n-1; i>=n; --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 ARR << " -> " << | |
#define PNT(STR) #STR | |
#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 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 priority_queue<P, vector<P>, greater<P> > pvqueue; | |
#define N 103 | |
#define K 206 | |
int main() { | |
int n, k, p[N]; | |
static double dp[N][K][K]; | |
cin >> n >> k; | |
rep(i, n) cin >> p[i]; | |
rep(i, n) rep(j, k) rep(kk, k) dp[i][j][kk] = 0.0; | |
dp[1][1][1] = 1.0; | |
repl(i, 1, n-1) { | |
repl(j, 1, k) { | |
repl(kk, j, k) { | |
if(j<kk) { | |
dp[i+1][j+2][kk] += dp[i][j][kk]*(double)p[i]/100.0; | |
if(kk+2 <= k) { | |
dp[i+1][j][kk+2] += dp[i][j][kk]*(double)(100-p[i])/100.0; | |
}else { | |
dp[i+1][j][kk] += dp[i][j][kk]*(double)(100-p[i])/100.0; | |
} | |
}else { | |
if(kk+1 <= k) { | |
dp[i+1][j+1][kk+1] += dp[i][j][kk]*(double)p[i]/100.0; | |
}else { | |
dp[i+1][j][kk] += dp[i][j][kk]*(double)p[i]/100.0; | |
} | |
if(kk+2 <= k) { | |
dp[i+1][j][kk+2] += dp[i][j][kk]*(double)(100-p[i])/100.0f; | |
}else { | |
dp[i+1][j][kk] += dp[i][j][kk]*(double)(100-p[i])/100.0; | |
} | |
} | |
} | |
} | |
} | |
double ans = 0.0; | |
repl(i, 1, k) { | |
repl(j, i, k) { | |
ans += dp[n][i][j]*((j-i)/2 + (k-j)); | |
} | |
} | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment