代码
服务器错误时敲的模板
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-1
开局手敲漏了一个句号(大意了,没有闪)
L1-2
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { int a = read(), b = read(), c = read(); cout << 1ll * a * b * c << endl; #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-3
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { double liq = 2.455, g = 1.26; double a, b, c, res; cin >> a >> b >> c; if(b == 0) { res = a * liq; } else res = a * g; printf("%.2f ", res); if(res - c > 0) cout << "T_T" << endl; else cout << "^_^" << endl; #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-4
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { int n = read(); double sum = 0; for(int i = 0; i < n; ++ i) { double tmp; cin >> tmp; sum += 1.0 / tmp; } printf("%.2f", 1.0 / (sum / (1.0 * n))); #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-5
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { int a = read(), b = read(), c = read(), d = read(); int min_a = read(), res = read(); int max_num = max(a, max(b, max(c, d))); int cnt = 0; vector<int> ans; if(max_num - a > res || a < min_a) cnt ++, ans.push_back(1); if(max_num - b > res || b < min_a) cnt ++, ans.push_back(2); if(max_num - c > res || c < min_a) cnt ++, ans.push_back(3); if(max_num - d > res || d < min_a) cnt ++, ans.push_back(4); // cout << max_num << endl; if(cnt == 0) puts("Normal"); else if(cnt == 1) cout << "Warning: please check #" << ans[0] << "!"; else puts("Warning: please check all the tires!"); #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-6(13分)
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } string a = "chi1 huo3 guo1"; int main() { int cnt = 0, mark = 0, first = 507; string s; while(1) { getline(cin, s); if(s == ".") break; cnt ++; int SZ = s.length(); for(int i = 0; i < SZ; ++ i) { // if(s[i] == 'c') { // cout << s.substr(i, 14) << "111" << endl; if(s.substr(i, 14) == a) { first = min(first, cnt); mark ++; } // } } } cout << cnt << endl; if(mark == 0) puts("-_-#"); else cout << first << ' ' << mark; #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-7
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { int n = read(), m = read(); for(int i = 0; i < m; ++ i) { string s; cin >> s; ll tmp = pow(2, n - 1); ll ans = 0; for(int j = 0; j < n; ++ j) { if(s[j] == 'n') ans += tmp; tmp /= 2; } cout << ans + 1 << endl; } #ifndef ONLINE_JUDGE system("pause"); #endif }
L1-8(18分)
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int maze[5][5]; int cx, cy, cnum; int gao(int x) { if(x <= 3) return maze[x][1] + maze[x][2] + maze[x][3]; else if(x <=6) return maze[1][x] + maze[2][x] + maze[3][x]; else if(x == 7) return maze[1][1] + maze[2][2] + maze[3][3]; else return maze[1][3] + maze[2][2] + maze[3][1]; } int mark[20]; int money[] = {0, 0, 0, 0, 0, 0, 10000, 36, 720, 360, 80, 252, 108, 72, 54, 180, 72, 180, 119, 36, 306, 1080, 144, 1800, 3600}; int main() { memset(maze, 0, sizeof(maze)); memset(mark, 0, sizeof(mark)); for(int i = 1; i <= 3; ++ i) { for(int j = 1; j <= 3; ++ j) { maze[i][j] = read(); if(maze[i][j] == 0) cx = i, cy = j; mark[maze[i][j]] = 1; } } for(int i = 1; i <= 9; ++ i) { if(mark[i] == 0) { cnum = i; maze[cx][cy] = i; break; } } for(int i = 0; i < 3; ++ i) { int x = read(), y = read(); cout << maze[x][y] << endl; } int choose = read(); cout << money[gao(choose)] << endl; #ifndef ONLINE_JUDGE system("pause"); #endif }
L2-1
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int main() { stack<int> st1; stack<char> st2; int n = read(); for(int i = 0; i < n ; ++ i) { int tmp = read(); st1.push(tmp); } for(int i = 0; i < n - 1; ++ i) { char c; cin >> c; st2.push(c); } while(!st2.empty()) { int n1 = st1.top(); st1.pop(); int n2 = st1.top(); st1.pop(); char c = st2.top(); st2.pop(); if(c == '+') st1.push(n1 + n2); else if(c == '-') st1.push(n2 - n1); else if(c == '*') st1.push(n2 * n1); else { if(n1 == 0) return cout << "ERROR: " << n2 << "/" << n1 << endl, 0; else st1.push(1.0 * n2 / n1); } } cout << st1.top() << endl; #ifndef ONLINE_JUDGE system("pause"); #endif }
L2-2(21分)
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } map<string, string> name; map<string, int> day; map<string, int> mk, mk2; struct peo{ string name, add; int st, time; }P[MAXNe5]; bool cmp(peo a, peo b) { return a.time < b.time; } bool judge(string s) { int SZ = s.length(); if(SZ != 18) return false; for(int i = 0; i < SZ; ++ i) { if(s[i] < '0' || s[i] > '9') return false; } return true; } int main() { int d = read(), p = read(); vector<string> res; for(int i = 1; i <= d; ++ i) { int t = read(), s = read(); for(int j = 0; j < t; ++ j) { string na, add; cin >> na >> add; int st, h, m; scanf("%d %d:%d", &st, &h, &m); P[j].name = na; P[j].add = add; P[j].st = st; P[j].time = h * 60 + m; if(judge(P[j].add)) { if(mk[add] != 1) { mk[add] = 1; day[add] = 0; name[add] = na; } if(mk2[add] != 1 && st == 1) { mk2[add] = 1; res.push_back(add); } } } if(t != 1) sort(P, P + t, cmp); // puts("------------------"); for(int j = 0, cnt = 0; cnt < s && j < t; ++ j) { if((i - day[P[j].add] >= p + 1 || day[P[j].add] == 0) && judge(P[j].add)) { cnt ++; day[P[j].add] = i; cout << P[j].name << ' ' << P[j].add << endl; } } // puts("-------------------"); } for(int i = 0; i < res.size(); ++ i) { cout << name[res[i]] << ' ' << res[i] << endl; } #ifndef ONLINE_JUDGE system("pause"); #endif } /* 4 2 5 3 A 123456789012345670 1 13:58 B 123456789012345671 0 13:58 C 12345678901234567 0 13:22 D 123456789012345672 0 03:24 C 123456789012345673 0 13:59 4 3 A 123456789012345670 1 13:58 E 123456789012345674 0 13:59 C 123456789012345673 0 13:59 F F 0 14:00 1 3 E 123456789012345674 1 13:58 1 1 A 123456789012345670 0 14:11 // day1 D 123456789012345672 A 123456789012345670 B 123456789012345671 //day2 E 123456789012345674 C 123456789012345673 //day3 //day4 A 123456789012345670 //remain A 123456789012345670 E 123456789012345674 */
L2-3
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int num[MAXNe5]; int tree[MAXNe5]; int n, cnt = 1; void build(int rt) { tree[rt] = num[cnt ++]; if(rt * 2 + 1 <= n) build(rt * 2 + 1); if(rt * 2 <= n) build(rt * 2); } int main() { n = read(); for(int i = n; i >= 1; -- i) num[i] = read(); build(1); queue<int> qe; qe.push(1); vector<int> ans; while(!qe.empty()) { int tmp = qe.front(); qe.pop(); ans.push_back(tree[tmp]); if(tmp * 2 <= n) qe.push(tmp * 2); if(tmp * 2 + 1 <= n) qe.push(tmp * 2 + 1); } for(int i = 0; i < ans.size(); ++ i) { cout << ans[i]; if(i + 1 != ans.size()) cout << ' '; } #ifndef ONLINE_JUDGE system("pause"); #endif }
L2-4
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } //struct edge{ // int to, next, val; //}Edge[MAXNe5]; //int head[MAXNe5], cnt = 1; //void add(int u, int v, int w) { // Edge[cnt].to = v; // Egde[val].val = w; // Edge[cnt].next = head[u]; // head[u] = cnt ++; //} int maze[1007][1007]; int vis[1007]; int main() { int n = read(), m = read(); // memset(head, 0, sizeof(head)); memset(maze, 0, sizeof(maze)); for(int i = 0; i < m; ++ i) { int u = read(), v = read(), w = read(); // add(u, v, w); maze[u][v] = w; maze[v][u] = w; } int t = read(); int cnt1 = 0, mark = 0, min_num = mod; for(int _ = 1; _ <= t; ++ _) { int tn = read(); vector<int> r; r.push_back(0); for(int i = 0; i < tn; ++ i) { int tmp = read(); r.push_back(tmp); } r.push_back(0); int SZ = r.size(); int cost = 0, tag = 1; memset(vis, 0, sizeof(vis)); for(int i = 0; i < SZ - 1; ++ i) { if(maze[r[i]][r[i + 1]] == 0 || vis[r[i + 1]]) { tag = 0; break; } vis[r[i + 1]] = 1; cost += maze[r[i]][r[i + 1]]; } if(tag == 1) { int tag2 = 1; for(int i = 1; i <= n; ++ i) if(vis[i] == 0) { tag2 = 0; break; } if(tag2 == 0) continue; cnt1 ++; if(cost < min_num) { min_num = cost; mark = _; } } } cout << cnt1 << '\n' << mark << ' ' << min_num << endl; #ifndef ONLINE_JUDGE system("pause"); #endif }
L3-1(9分)
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long long mod = 1e9 + 7; const int MAXNe5 = 1e5 + 7; const int MAXNe6 = 1e6 + 7; inline long long read() { long long res = 0, flag = 1; char c = getchar(); while(c < '0' || c > '9') {if(c == '-') flag = -1; c = getchar();} while(c >= '0' && c <= '9') { res = res * 10 + (c - '0'); c = getchar();} return res * flag; } int maze[507][507]; int vis[5007]; int main() { memset(maze, 0, sizeof(maze)); int n = read(), m = read(); for(int i = 0; i < m; ++ i) { int u = read(), v = read(); maze[u][v] = 1; maze[v][u] = 1; } int st = read(), ed = read(); queue<int> qe; qe.push(st); int cnt = 0; int judge = 1; while(!qe.empty()) { int p = qe.front(); qe.pop(); // cout << p << endl; if(vis[p]) continue; vis[p] = 1; int tag = 0; for(int i = 0; i <= n; ++ i) { if(i == p) continue; if(maze[p][i] == 1) { // cout << i << endl; if(i == ed) cnt ++; else if(vis[i] == 0){ qe.push(i); } tag = 1; } } if(tag == 0) judge = 0; } cout << cnt << ' ' << (judge == 0 ? "No" : "Yes") << endl; }