buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <cmath> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; double dp[12][1 << 12]; int main() { int width; while (cin >> width) { for (int i = 0; i < 12; ++i) { for (int j = 0; j < (1 << 12); ++j) { dp[i][j] = -1.0; } } string line; getline(cin, line); stringstream ss(line); vector<int> cakes; int r; while (ss >> r) { cakes.push_back(r); int index = cakes.size() - 1; dp[index][1 << index] = static_cast<double>(r * 2); } int n = cakes.size(); for (int j = 0; j < (1 << n); ++j) { for (int i = 0; i < n; ++i) { if (!(j & (1 << i))) { continue; } for (int k = 0; k < n; ++k) { if (j & (1 << k)) { continue; } int mask = j | (1 << k); double c = cakes[i] + cakes[k]; double a = cakes[i] - cakes[k]; double b = sqrt(c * c - a * a); double p = dp[i][j] - cakes[i] + b + cakes[k]; dp[k][mask] = (dp[k][mask] < 0.0 ? p : min(dp[k][mask], p)); } } } bool flag = (n == 0); for (int i = 0; i < n; ++i) { if (dp[i][(1 << n) - 1] <= width + 1e-6) { flag = true; } } cout << (flag ? "OK" : "NG") << endl; } return 0; }
#include <cmath> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; double dp[12][1 << 12]; int main() { int width; while (cin >> width) { for (int i = 0; i < 12; ++i) { for (int j = 0; j < (1 << 12); ++j) { dp[i][j] = -1.0; } } string line; getline(cin, line); stringstream ss(line); vector<int> cakes; int r; while (ss >> r) { cakes.push_back(r); int index = cakes.size() - 1; dp[index][1 << index] = static_cast<double>(r * 2); } int n = cakes.size(); for (int j = 0; j < (1 << n); ++j) { for (int i = 0; i < n; ++i) { if (!(j & (1 << i))) { continue; } for (int k = 0; k < n; ++k) { if (j & (1 << k)) { continue; } int mask = j | (1 << k); double c = cakes[i] + cakes[k]; double a = cakes[i] - cakes[k]; double b = sqrt(c * c - a * a); double p = dp[i][j] - cakes[i] + b + cakes[k]; dp[k][mask] = (dp[k][mask] < 0.0 ? p : min(dp[k][mask], p)); } } } bool flag = (n == 0); for (int i = 0; i < n; ++i) { if (dp[i][(1 << n) - 1] <= width + 1e-6) { flag = true; } } cout << (flag ? "OK" : "NA") << endl; } return 0; }
[["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
430
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int lli; typedef pair<int, int> P; #define F first #define S second const int INF = 1000000000; int main() { string str; while (getline(cin, str)) { stringstream s; s << str; int l; s >> l; vector<int> r; while (!s.eof()) { int tmp; s >> tmp; r.push_back(tmp); } double dp[1 << 12][12]; double d[12][12]; int n = (int)r.size(); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { d[i][j] = 2 * sqrt(r[i] * r[j]); } } for (int S = 0; S < (1 << n); ++S) { fill(dp[S], dp[S] + n, INF); } for (int i = 0; i < n; ++i) { dp[(1 << n) - 1 - (1 << i)][i] = r[i]; } for (int S = (1 << n) - 2; S >= 0; --S) { for (int j = 0; j < n; ++j) { if (!(1 & (1 << j))) { for (int k = 0; k < n; ++k) { if (S == 0) dp[S][j] = min(dp[S][j], dp[S | 1 << j][k] + d[j][k] + r[j]); else dp[S][j] = min(dp[S][j], dp[S | 1 << j][k] + d[j][k]); } } } } double res = INF; for (int i = 0; i < n; ++i) { res = min(res, dp[0][i]); // cout << dp[0][i] << "\n"; } if (res <= l) cout << "OK\n"; else cout << "NA\n"; // cout << res << "\n"; } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int lli; typedef pair<int, int> P; #define F first #define S second const int INF = 1000000000; int main() { string str; while (getline(cin, str)) { stringstream s; s << str; int l; s >> l; vector<int> r; while (!s.eof()) { int tmp; s >> tmp; r.push_back(tmp); } double dp[1 << 12][12]; double d[12][12]; int n = (int)r.size(); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { d[i][j] = 2 * sqrt(r[i] * r[j]); } } for (int S = 0; S < (1 << n); ++S) { fill(dp[S], dp[S] + n, INF); } for (int i = 0; i < n; ++i) { dp[(1 << n) - 1 - (1 << i)][i] = r[i]; } for (int S = (1 << n) - 2; S >= 0; --S) { for (int j = 0; j < n; ++j) { if (!(S & (1 << j))) { for (int k = 0; k < n; ++k) { if (S == 0) dp[S][j] = min(dp[S][j], dp[S | 1 << j][k] + d[j][k] + r[j]); else dp[S][j] = min(dp[S][j], dp[S | 1 << j][k] + d[j][k]); } } } } double res = INF; for (int i = 0; i < n; ++i) { res = min(res, dp[0][i]); // cout << dp[0][i] << "\n"; } if (res <= l) cout << "OK\n"; else cout << "NA\n"; // cout << res << "\n"; } return 0; }
[["-", 15, 339, 51, 91, 28, 23, 0, 16, 31, 13], ["+", 15, 339, 51, 91, 28, 23, 0, 16, 31, 22]]
1
510
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n)-1) const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 10; #define LE(x, y) ((x) - (y) < EPS) typedef vector<double> vd; vs split(string str, string delim) { vs result; int pos; while ((pos = str.find_first_of(delim)) != str.npos) { if (pos > 0) { result.push_back(str.substr(0, pos)); } str = str.substr(pos + 1); } if (str.length() > 0) { result.push_back(str); } return result; } double diff(int r1, int r2) { return 2 * sqrt(r1 * r2) - r1 + r2; } int main() { string line; while (getline(cin, line)) { vs data = split(line, " "); double size = toInt(data[0]); int n = data.size() - 1; vi r(n); REP(i, n) { r[i] = toInt(data[i + 1]); } vector<vd> dp(1 << n, vd(n, INF)); REP(i, n) { dp[1 << i][i] = 2 * r[i]; } REP(i, 1 << n) { REP(j, n) { if (i & (1 << j)) { REP(k, n) { int ni = i | (1 << k); if (i != ni) { dp[ni][k] = min(dp[ni][k], dp[i][j] + diff(r[j], r[k])); } } } } } bool ok = false; REP(i, n) { if (LE(dp[(1 << n) - 1][i], size)) { ok = true; } } cout << (ok ? "OK" : "NG") << endl; } return 0; }
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); } typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, n) FOR(i, 0, (n)-1) const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 10; #define LE(x, y) ((x) - (y) < EPS) typedef vector<double> vd; vs split(string str, string delim) { vs result; int pos; while ((pos = str.find_first_of(delim)) != str.npos) { if (pos > 0) { result.push_back(str.substr(0, pos)); } str = str.substr(pos + 1); } if (str.length() > 0) { result.push_back(str); } return result; } double diff(int r1, int r2) { return 2 * sqrt(r1 * r2) - r1 + r2; } int main() { string line; while (getline(cin, line)) { vs data = split(line, " "); double size = toInt(data[0]); int n = data.size() - 1; vi r(n); REP(i, n) { r[i] = toInt(data[i + 1]); } vector<vd> dp(1 << n, vd(n, INF)); REP(i, n) { dp[1 << i][i] = 2 * r[i]; } REP(i, 1 << n) { REP(j, n) { if (i & (1 << j)) { REP(k, n) { int ni = i | (1 << k); if (i != ni) { dp[ni][k] = min(dp[ni][k], dp[i][j] + diff(r[j], r[k])); } } } } } bool ok = false; REP(i, n) { if (LE(dp[(1 << n) - 1][i], size)) { ok = true; } } cout << (ok ? "OK" : "NA") << endl; } return 0; }
[["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
597
#include <algorithm> #include <cfloat> #include <cmath> #include <cstdio> using namespace std; int main() { char buf[200]; int r[12]; double p[12][12]; double dp[1 << 12][12]; double ans; int w; int n, iread, ibuf; int v; while (fgets(buf, sizeof(buf), stdin)) { n = 0; ibuf = 0; sscanf(buf, "%d%n", &w, &iread); ibuf += iread; while (n < 12 && sscanf(buf + ibuf, "%d%n", &r[n], &iread) == 1) { n++; ibuf += iread; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { p[i][j] = 0.0; } else { p[i][j] = 2.0 * sqrt(r[i] * r[j]); } } } for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < n; j++) { dp[i][j] = DBL_MAX; } } v = (1 << n) - 1; for (int i = 0; i < n; i++) dp[v][i] = r[i]; --v; while (v) { for (int i = 0; i < n; i++) { if (!(v & (1 << i))) continue; for (int j = 0; j < n; j++) { if (v & (1 << j)) continue; dp[v][i] = min(dp[v][i], dp[v | (1 << j)][j] + p[i][j]); } } --v; } ans = DBL_MAX; for (int i = 0; i < n; i++) { ans = min(ans, dp[1 << i][i] + r[i]); } if (ans <= w) { printf("OK\n"); } else { printf("NG\n"); } } return 0; }
#include <algorithm> #include <cfloat> #include <cmath> #include <cstdio> using namespace std; int main() { char buf[200]; int r[12]; double p[12][12]; double dp[1 << 12][12]; double ans; int w; int n, iread, ibuf; int v; while (fgets(buf, sizeof(buf), stdin)) { n = 0; ibuf = 0; sscanf(buf, "%d%n", &w, &iread); ibuf += iread; while (n < 12 && sscanf(buf + ibuf, "%d%n", &r[n], &iread) == 1) { n++; ibuf += iread; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { p[i][j] = 0.0; } else { p[i][j] = 2.0 * sqrt(r[i] * r[j]); } } } for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < n; j++) { dp[i][j] = DBL_MAX; } } v = (1 << n) - 1; for (int i = 0; i < n; i++) dp[v][i] = r[i]; --v; while (v) { for (int i = 0; i < n; i++) { if (!(v & (1 << i))) continue; for (int j = 0; j < n; j++) { if (v & (1 << j)) continue; dp[v][i] = min(dp[v][i], dp[v | (1 << j)][j] + p[i][j]); } } --v; } ans = DBL_MAX; for (int i = 0; i < n; i++) { ans = min(ans, dp[1 << i][i] + r[i]); } if (ans <= w) { printf("OK\n"); } else { printf("NA\n"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
489
import java.util.ArrayDeque; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { int[] init = {0, 1, 2, 3, 4, 5, 6, 7}; HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); map.put(encode(init), 0); ArrayDeque<int[]> que = new ArrayDeque<int[]>(); que.add(init); while (!que.isEmpty()) { int[] arr = que.remove(); int[][] swap = {{0, 1}, {1, 2}, {2, 3}, {4, 5}, {5, 6}, {6, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}; for (int[] ij : swap) { int i = ij[0], j = ij[1]; if (arr[i] == 0 || arr[j] == 0) { int[] _arr = arr.clone(); _arr[i] = arr[j]; _arr[j] = arr[i]; if (!map.containsKey(encode(_arr))) { map.put(encode(_arr), map.get(encode(arr)) + 1); que.add(_arr); } } } } Scanner in = new Scanner(System.in); while (in.hasNext()) { int[] arr = new int[8]; for (int i = 0; i < 8; i++) { arr[i] = in.nextInt(); } System.out.println(map.get(encode(arr))); } } static int encode(int[] arr) { int code = 0; for (int n : arr) { code = code << 3 + n; } return code; } }
import java.util.ArrayDeque; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { int[] init = {0, 1, 2, 3, 4, 5, 6, 7}; HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); map.put(encode(init), 0); ArrayDeque<int[]> que = new ArrayDeque<int[]>(); que.add(init); while (!que.isEmpty()) { int[] arr = que.remove(); int[][] swap = {{0, 1}, {1, 2}, {2, 3}, {4, 5}, {5, 6}, {6, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}; for (int[] ij : swap) { int i = ij[0], j = ij[1]; if (arr[i] == 0 || arr[j] == 0) { int[] _arr = arr.clone(); _arr[i] = arr[j]; _arr[j] = arr[i]; if (!map.containsKey(encode(_arr))) { map.put(encode(_arr), map.get(encode(arr)) + 1); que.add(_arr); } } } } Scanner in = new Scanner(System.in); while (in.hasNext()) { int[] arr = new int[8]; for (int i = 0; i < 8; i++) { arr[i] = in.nextInt(); } System.out.println(map.get(encode(arr))); } } static int encode(int[] arr) { int code = 0; for (int n : arr) { code = (code << 3) + n; } return code; } }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]]
3
438
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> //反向bfs using namespace std; map<string, int> t; int num; int mv[] = {-4, 4, 1, -1}; //上下右左 void bfs(string st) { queue<string> q; t[st] = 1; q.push(st); while (!q.empty()) { st = q.front(), q.pop(); int nu = st.find('0'); for (int i = 0; i < 4; ++i) // { // int tn=nu+mv[i]; // if(tn<0||tn>7||tn==3&&mv[i]==1||tn==4&&mv[i]==-1) // continue; // string tp=st; // swap(tp[nu],tp[nu+mv[i]]); // if(!t[tp]) // { // q.push(tp); // t[tp]=t[st]+1; // } // // // } // } // // t[st]=1;q.push(st); //起始状? // while(!q.empty()) // { // st=q.front();q.pop(); // int num=st.find('0');//找到空格位置 // for(int i=0;i<4;++i) { int tn = num + mv[i]; //可能??的数? if (tn < 0 || tn > 7 || num == 3 && mv[i] == 1 || num == 4 && mv[i] == -1) //空格在3的?候,4不能??,因?3 4 不相?,反之同理 { continue; } string tp = st; swap(tp[num], tp[num + mv[i]]); //移?物? if (!t[tp]) //未出??的状? { q.push(tp); t[tp] = t[st] + 1; } } } } int main() { string st = "01234567"; bfs(st); while (scanf("%d", &num) != EOF) { st[0] = num + '0'; for (int i = 1; i < 8; i++) { scanf("%d", &num); st[i] = num + '0'; } cout << t[st] - 1 << endl; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> //反向bfs using namespace std; map<string, int> t; int num; int mv[] = {-4, 4, 1, -1}; //上下右左 void bfs(string st) { queue<string> q; t[st] = 1; q.push(st); while (!q.empty()) { st = q.front(), q.pop(); int num = st.find('0'); for (int i = 0; i < 4; ++i) // { // int tn=num+mv[i]; // if(tn<0||tn>7||tn==3&&mv[i]==1||tn==4&&mv[i]==-1) // continue; // string tp=st; // swap(tp[num],tp[num+mv[i]]); // if(!t[tp]) // { // q.push(tp); // t[tp]=t[st]+1; // } // // // } // } // // t[st]=1;q.push(st); //起始状? // while(!q.empty()) // { // st=q.front();q.pop(); // int num=st.find('0');//找到空格位置 // for(int i=0;i<4;++i) { int tn = num + mv[i]; //可能??的数? if (tn < 0 || tn > 7 || num == 3 && mv[i] == 1 || num == 4 && mv[i] == -1) //空格在3的?候,4不能??,因?3 4 不相?,反之同理 { continue; } string tp = st; swap(tp[num], tp[num + mv[i]]); //移?物? if (!t[tp]) //未出??的状? { q.push(tp); t[tp] = t[st] + 1; } } } } int main() { string st = "01234567"; bfs(st); while (scanf("%d", &num) != EOF) { st[0] = num + '0'; for (int i = 1; i < 8; i++) { scanf("%d", &num); st[i] = num + '0'; } cout << t[st] - 1 << endl; } }
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22]]
1
352
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <string> // aoj 0121 广度优先搜索 //将一组数字看作一个状态,遍历所有的状态空间,放在res中 using namespace std; int d[4] = {1, -1, 4, -4}; map<string, int> res; //用于存储所有状态空间 void slove() { queue<string> que; que.push("01234567"); while (!que.empty()) { string s = que.front(); que.pop(); // pos用于记录其中0的位置 int pos; for (int i = 0; i < 8; i++) { if (s[i] == '0') pos = i; } for (int i = 0; i < 4; i++) { if (pos + d[i] >= 0 && pos + d[i] < 8 && !(pos == 3 && i == 0) && !(pos = 4 && i == 1)) { string u = s; swap(u[pos], u[pos + d[i]]); if (res[u] == 0) { que.push(u); res[u] = res[s] + 1; } } } } } int main() { int in; res["01234567"] = 1; slove(); while (true) { string s; for (int i = 0; i < 8; i++) { if (!(cin >> in)) return 0; s += in + '0'; } cout << res[s] - 1 << endl; } return 0; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <string> // aoj 0121 广度优先搜索 //将一组数字看作一个状态,遍历所有的状态空间,放在res中 using namespace std; int d[4] = {1, -1, 4, -4}; map<string, int> res; //用于存储所有状态空间 void slove() { queue<string> que; que.push("01234567"); while (!que.empty()) { string s = que.front(); que.pop(); // pos用于记录其中0的位置 int pos; for (int i = 0; i < 8; i++) { if (s[i] == '0') pos = i; } for (int i = 0; i < 4; i++) { if (pos + d[i] >= 0 && pos + d[i] < 8 && !(pos == 3 && i == 0) && !(pos == 4 && i == 1)) { string u = s; swap(u[pos], u[pos + d[i]]); if (res[u] == 0) { que.push(u); res[u] = res[s] + 1; } } } } } int main() { int in; res["01234567"] = 1; slove(); while (true) { string s; for (int i = 0; i < 8; i++) { if (!(cin >> in)) return 0; s += in + '0'; } cout << res[s] - 1 << endl; } return 0; }
[["-", 12, 91, 28, 23, 0, 16, 0, 42, 0, 32], ["+", 12, 91, 28, 23, 0, 16, 31, 16, 17, 60]]
1
317
N = eval(input()) while True: dic = {} for i in range(N): lis = input().split() dic[lis[0]] = [3*int(lis[1])+int(lis[3]), N-i] for k, v in sorted(list(dic.items()), key=lambda x: (x[0][0], x[0][1]), reverse=True): print('%s,%s' % (k, v[0])) N = eval(input()) if N == 0: break print()
N = eval(input()) while True: dic = {} for i in range(N): lis = input().split() dic[lis[0]] = [3*int(lis[1])+int(lis[3]), N-i] for k, v in sorted(list(dic.items()), key=lambda x: (x[1][0], x[1][1]), reverse=True): print('%s,%s' % (k, v[0])) N = eval(input()) if N == 0: break print()
[["-", 51, 670, 8, 660, 0, 206, 51, 206, 206, 612], ["+", 51, 670, 8, 660, 0, 206, 51, 206, 206, 612]]
5
139
b=False while True: n = int(input()) if n==0:break d=dict() if b:print() b=True for _ in range(n): line = input().split() tmp = int(line[1])*3+int(line[3]*1) if tmp in d: d[tmp].append(line[0]) else: d[tmp] = [] d[tmp].append(line[0]) for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]: for v in vs: print('{0},{1}'.format(k, v))
b=False while True: n = int(input()) if n==0:break d=dict() if b:print() b=True for _ in range(n): line = input().split() tmp = int(line[1])*3+int(line[3]*1) if tmp in d: d[tmp].append(line[0]) else: d[tmp] = [] d[tmp].append(line[0]) for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]: for v in vs: print('{0},{1}'.format(v, k))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
158
n=eval(input()) while True: p={} for i in range(n): t=input().split() p[t[0]] = [3*int(t[1])+1*int(t[3]),i] for k,v in sorted(list(p.items()),key=lambda x:x[1])[::-1]: print("%s,%d"%(k,v[0])) n=eval(input()) if n==0:break print()
n=eval(input()) while True: p={} for i in range(n): t=input().split() p[t[0]] = [3*int(t[1])+1*int(t[3]),-i] for k,v in sorted(list(p.items()),key=lambda x:x[1])[::-1]: print("%s,%d"%(k,v[0])) n=eval(input()) if n==0:break print()
[["+", 0, 1, 0, 662, 12, 634, 0, 664, 17, 33]]
5
128
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); ; int INF = 1 << 28; double EPS = 1e-9; void run() { for (;;) { int y1 = sc.nextInt(); int m1 = sc.nextInt(); int d1 = sc.nextInt(); int y2 = sc.nextInt(); int m2 = sc.nextInt(); int d2 = sc.nextInt(); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } int a = day(y1, m1, d1); int b = day(y2, m2, d2); println((b - a) + ""); } } int day(int y, int m, int d) { int res = 0; int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < m - 1; i++) { res += days[i - 1]; } res += y * 365 + d - 1; if ((m == 2 && d <= 28) || m == 1) { y--; } if (y >= 0) { res += y / 4 + 1; res -= y / 100 + 1; res += y / 400 + 1; } return res; } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } void print(String s) { System.out.print(s); } void println(String s) { System.out.println(s); } public static void main(String[] args) { new Main().run(); } }
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc = new Scanner(System.in); ; int INF = 1 << 28; double EPS = 1e-9; void run() { for (;;) { int y1 = sc.nextInt(); int m1 = sc.nextInt(); int d1 = sc.nextInt(); int y2 = sc.nextInt(); int m2 = sc.nextInt(); int d2 = sc.nextInt(); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } int a = day(y1, m1, d1); int b = day(y2, m2, d2); println((b - a) + ""); } } int day(int y, int m, int d) { int res = 0; int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < m - 1; i++) { res += days[i]; } res += y * 365 + d - 1; if ((m == 2 && d <= 28) || m == 1) { y--; } if (y >= 0) { res += y / 4 + 1; res -= y / 100 + 1; res += y / 400 + 1; } return res; } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } void print(String s) { System.out.print(s); } void println(String s) { System.out.println(s); } public static void main(String[] args) { new Main().run(); } }
[["-", 0, 1, 0, 11, 12, 504, 71, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 504, 71, 16, 12, 499]]
3
411
import java.util.Scanner; public class Main { static final int[] md = new int[12]; static { int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int day = 0; for (int i = 0; i < 12; i++) { md[i] = day; day += days[i]; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int y1, y2, m1, m2, d1, d2; while (true) { if ((y1 = in.nextInt()) < 0 || (m1 = in.nextInt()) < 0 || (d1 = in.nextInt()) < 0 || (y2 = in.nextInt()) < 0 || (m2 = in.nextInt()) < 0 || (d2 = in.nextInt()) < 0) { break; } long from = getL(y1, m1, d1); long to = getL(y2, m2, d2); System.out.println(to - from); } } private static long getL(int y, int m, int d) { long result = 365 * y + md[m - 1] + d; if (m > 2 && (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))) { result++; } result += (y - 1) / 4 - (y - 1) / 100 - (y - 1) / 400; return result; } }
import java.util.Scanner; public class Main { static final int[] md = new int[12]; static { int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int day = 0; for (int i = 0; i < 12; i++) { md[i] = day; day += days[i]; } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int y1, y2, m1, m2, d1, d2; while (true) { if ((y1 = in.nextInt()) < 0 || (m1 = in.nextInt()) < 0 || (d1 = in.nextInt()) < 0 || (y2 = in.nextInt()) < 0 || (m2 = in.nextInt()) < 0 || (d2 = in.nextInt()) < 0) { break; } long from = getL(y1, m1, d1); long to = getL(y2, m2, d2); System.out.println(to - from); } } private static long getL(int y, int m, int d) { long result = 365 * y + md[m - 1] + d; if (m > 2 && ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)) { result++; } result += (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400; return result; } }
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 16, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72]]
3
343
#include <stdio.h> int is_leap(int y) { if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) { return (1); } else { return (0); } } int day_count(int y, int m, int d) { int cnt = 0; cnt += d; while (m > 0) { if (m == 2) { if (is_leap(y) == 1) { cnt += 29; } else { cnt += 28; } } else if (m == 4 || m == 6 || m == 9 || m == 11) { cnt += 30; } else { cnt += 31; } m--; } y--; while (y > 0) { if (is_leap(y) == 1) { cnt += 366; } else { cnt += 365; } y--; } return (cnt); } int main(void) { int y1, m1, d1; int y2, m2, d2; int cnt1, cnt2; while (scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2)) { if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } cnt1 = day_count(y1, m1, d1); cnt2 = day_count(y2, m2, d2); printf("%d\n", cnt2 - cnt1); } return (0); }
#include <stdio.h> int is_leap(int y) { if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) { return (1); } else { return (0); } } int day_count(int y, int m, int d) { int cnt = 0; cnt += d; m--; while (m > 0) { if (m == 2) { if (is_leap(y) == 1) { cnt += 29; } else { cnt += 28; } } else if (m == 4 || m == 6 || m == 9 || m == 11) { cnt += 30; } else { cnt += 31; } m--; } y--; while (y > 0) { if (is_leap(y) == 1) { cnt += 366; } else { cnt += 365; } y--; } return (cnt); } int main(void) { int y1, m1, d1; int y2, m2, d2; int cnt1, cnt2; while (scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2)) { if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } cnt1 = day_count(y1, m1, d1); cnt2 = day_count(y2, m2, d2); printf("%d\n", cnt2 - cnt1); } return (0); }
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
310
a, b, c; main(d, e, f) { for (; scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f), ~a; printf("%d\n", (365 * d + d / 4 - d / 100 + d / 400 + 306 * (e + 1) / 10 - 428 + f) - (365 * a + a / 4 - a / 100 + a / 400 + 306 * (b + 1) / 10 - 428 + c))) { b > 2 ?: a--, b += 12; e > 2 ?: d--, e += 12; } exit(0); }
a, b, c; main(d, e, f) { for (; scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f), ~a; printf("%d\n", (365 * d + d / 4 - d / 100 + d / 400 + 306 * (e + 1) / 10 - 428 + f) - (365 * a + a / 4 - a / 100 + a / 400 + 306 * (b + 1) / 10 - 428 + c))) { b > 2 ?: (a--, b += 12); e > 2 ?: (d--, e += 12); } exit(0); }
[["+", 8, 9, 0, 1, 0, 41, 75, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 41, 75, 23, 0, 25]]
0
151
#include <stdio.h> main() { int y1, m1, d3, y2, m2, d4, day[1000000] = {0}, i, j; double d1, d2; for (i = 0; i < 1000000; i++) { if (i % 400 == 0) day[i] = 1; else if (i % 4 == 0 && i % 100 != 0) day[i] = 1; } while (1) { d1 = 0, d2 = 0; scanf("%d %d %d %d %d %d", &y1, &m1, &d3, &y2, &m2, &d4); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) return 0; for (i = 0; i < y1; i++) { if (day[i] == 0) d1 += 365; else d1 += 366; } for (j = 0; j < y2; j++) { if (day[j] == 0) d2 += 365; else d2 += 366; } for (i = 1; i < m1; i++) { switch (i) { case 4: case 6: case 9: case 11: d1 += 30; break; case 2: if (day[y1] == 1) d1 += 29; else d1 += 28; break; default: d1 += 31; break; } } for (i = 1; i < m2; i++) { switch (i) { case 4: case 6: case 9: case 11: d2 += 30; break; case 2: if (day[y1] == 1) d2 += 29; else d2 += 28; break; default: d2 += 31; break; } } d1 += d3; d2 += d4; printf("%.0f\n", d2 - d1); } return 0; }
#include <stdio.h> main() { int y1, m1, d3, y2, m2, d4, day[1000000] = {0}, i, j; double d1, d2; for (i = 0; i < 1000000; i++) { if (i % 400 == 0) day[i] = 1; else if (i % 4 == 0 && i % 100 != 0) day[i] = 1; } while (1) { d1 = 0, d2 = 0; scanf("%d %d %d %d %d %d", &y1, &m1, &d3, &y2, &m2, &d4); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) return 0; for (i = 0; i < y1; i++) { if (day[i] == 0) d1 += 365; else d1 += 366; } for (j = 0; j < y2; j++) { if (day[j] == 0) d2 += 365; else d2 += 366; } for (i = 1; i < m1; i++) { switch (i) { case 4: case 6: case 9: case 11: d1 += 30; break; case 2: if (day[y1] == 1) d1 += 29; else d1 += 28; break; default: d1 += 31; break; } } for (i = 1; i < m2; i++) { switch (i) { case 4: case 6: case 9: case 11: d2 += 30; break; case 2: if (day[y2] == 1) d2 += 29; else d2 += 28; break; default: d2 += 31; break; } } d1 += d3; d2 += d4; printf("%.0f\n", d2 - d1); } return 0; }
[["-", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22]]
0
388
#include <stdio.h> #include <stdlib.h> #include <string.h> int y1, m1, d1, y2, m2, d2, year[10000], month[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int i, j, k; void swap(int *x, int *y) { int z; z = *x; *x = *y; *y = z; } int isleap(int y) { if (y % 400 == 0) return 1; if (y % 100 == 0) return 0; if (y % 4 == 0) return 1; return 0; } int serial(int y, int m, int d) { return year[y] + month[m - 1] + d + ((m > 3 && isleap(y)) ? 1 : 0); } int main() { for (i = 1; i < 10000; i++) year[i] = year[i - 1] + 365 + isleap(i - 1); while (scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2) && y1 >= 0) { printf("%d\n", serial(y2, m2, d2) - serial(y1, m1, d1)); } return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> int y1, m1, d1, y2, m2, d2, year[5000], month[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int i, j, k; void swap(int *x, int *y) { int z; z = *x; *x = *y; *y = z; } int isleap(int y) { if (y % 400 == 0) return 1; if (y % 100 == 0) return 0; if (y % 4 == 0) return 1; return 0; } int serial(int y, int m, int d) { return year[y] + month[m - 1] + d + ((m > 2 && isleap(y)) ? 1 : 0); } int main() { for (i = 1; i < 5000; i++) year[i] = year[i - 1] + 365 + isleap(i - 1); while (scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2) && y1 >= 0) { printf("%d\n", serial(y2, m2, d2) - serial(y1, m1, d1)); } return 0; }
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 41, 15, 23, 0, 16, 31, 16, 12, 13], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
0
286
#include <ctype.h> #include <stdio.h> #include <string.h> int main() { int y1, m1, d1, y2, m2, d2, i, j; int cnt = 0; int month[][12] = {{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}}; while (1) { cnt = 0; scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } i = y1 * 365 + month[!!(!(y1 % 4) && ((y1 % 100) || !(y1 % 400)))][m1 - 1] + d1 + ((y1 - 1) / 4) - ((y1 - 1) / 100) + ((y1 - 1) / 400); j = y2 * 365 + month[!!(!(y2 % 4) && ((y2 % 100) || !(y2 % 400)))][m2 - 1] + d2 + ((y2 - 1) / 4) - ((y2 - 1) / 100) + ((y2 - 1) / 400); printf("%d\n", i - j); } return 0; }
#include <ctype.h> #include <stdio.h> #include <string.h> int main() { int y1, m1, d1, y2, m2, d2, i, j; int cnt = 0; int month[][12] = {{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}}; while (1) { cnt = 0; scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) { break; } i = y1 * 365 + month[!!(!(y1 % 4) && ((y1 % 100) || !(y1 % 400)))][m1 - 1] + d1 + ((y1 - 1) / 4) - ((y1 - 1) / 100) + ((y1 - 1) / 400); j = y2 * 365 + month[!!(!(y2 % 4) && ((y2 % 100) || !(y2 % 400)))][m2 - 1] + d2 + ((y2 - 1) / 4) - ((y2 - 1) / 100) + ((y2 - 1) / 400); printf("%d\n", j - i); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
320
#include <bits/stdc++.h> using namespace std; int pm(int y, int m) { int sum = 0; int s[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < m; i++) { sum += s[i]; if (i == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) sum += 1; } return sum; } int main() { int y1, y2, m1, m2, d1, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > -1 && y2 > -1 && m1 > -1 && m2 > -1 && d1 > -1 && d2 > -1) { y1--; int t1 = y1 * 365 + (y1 / 400) - (y1 / 100) + (y1 / 4); y1++; t1 += d1; t1 += pm(y1, m1); y2--; int t2 = y2 * 365 + (y2 / 400) - (y2 / 100) + (y2 / 4); y2++; t2 += d2; t2 += pm(y2, m2); cout << t2 - t1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int pm(int y, int m) { int sum = 0; int s[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < m - 1; i++) { sum += s[i]; if (i == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) sum += 1; } return sum; } int main() { int y1, y2, m1, m2, d1, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > -1 && y2 > -1 && m1 > -1 && m2 > -1 && d1 > -1 && d2 > -1) { y1--; int t1 = y1 * 365 + (y1 / 400) - (y1 / 100) + (y1 / 4); y1++; t1 += d1; t1 += pm(y1, m1); y2--; int t2 = y2 * 365 + (y2 / 400) - (y2 / 100) + (y2 / 4); y2++; t2 += d2; t2 += pm(y2, m2); cout << t2 - t1 << endl; } return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
269
#include <iostream> using namespace std; bool isLeap(int y) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; if (y % 4 == 0) return true; return false; } int NumberOfDays(int y, int m, int d) { int num = 0; int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 30, 30, 31, 30, 31}; if (isLeap(y)) mon[2]++; for (int i = 1; i < y; i++) num += isLeap(i) ? 366 : 365; for (int i = 1; i < m; i++) num += mon[i]; num += d - 1; return num; } int main() { int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (!(~y1 && ~m1 && ~d1 && ~y2 && ~m2 && ~d2)) break; cout << NumberOfDays(y2, m2, d2) - NumberOfDays(y1, m1, d1) << endl; } return 0; }
#include <iostream> using namespace std; bool isLeap(int y) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; if (y % 4 == 0) return true; return false; } int NumberOfDays(int y, int m, int d) { int num = 0; int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (isLeap(y)) mon[2]++; for (int i = 1; i < y; i++) num += isLeap(i) ? 366 : 365; for (int i = 1; i < m; i++) num += mon[i]; num += d - 1; return num; } int main() { int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (!(~y1 && ~m1 && ~d1 && ~y2 && ~m2 && ~d2)) break; cout << NumberOfDays(y2, m2, d2) - NumberOfDays(y1, m1, d1) << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
257
#include <cstdio> bool isLeap(int year) { if (year % 400 == 0) return true; if (year % 100 == 0) return false; return (year % 4 == 0); } long long dateserial(int year, int month, int day) { static int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; long long res = day; for (int i = 0; i < month; ++i) { res += days[i]; if (isLeap(year) && i == 1) res++; } for (int i = 2; i < year; ++i) { res += 365; if (isLeap(i)) res++; } return res; } int main() { while (true) { int y1, m1, d1, y2, m2, d2; scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; long long date1 = dateserial(y1, m1, d1); long long date2 = dateserial(y2, m2, d2); printf("%d\n", date2 - date1); } return 0; }
#include <cstdio> bool isLeap(int year) { if (year % 400 == 0) return true; if (year % 100 == 0) return false; return (year % 4 == 0); } long long dateserial(int year, int month, int day) { static int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; long long res = day; for (int i = 0; i < month - 1; ++i) { res += days[i]; if (isLeap(year) && i == 1) res++; } for (int i = 1; i < year; ++i) { res += 365; if (isLeap(i)) res++; } return res; } int main() { while (true) { int y1, m1, d1, y2, m2, d2; scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2); if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; long long date1 = dateserial(y1, m1, d1); long long date2 = dateserial(y2, m2, d2); printf("%d\n", date2 - date1); } return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
284
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-5; typedef long long ll; int uru(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); } int day(int y, int m, int d) { int days = 0; for (int i = 1; i <= y - 1; i++) days += uru(i) + 365; if (m > 1) days += 31; if (m > 2) days += 28 + uru(y); if (m > 3) days += 31; if (m > 4) days += 30; if (m > 5) days += 31; if (m > 6) days += 30; if (m > 7) days += 31; if (m > 8) days += 30; if (m > 9) days += 30; if (m > 10) days += 31; if (m > 11) days += 30; days += d - 1; return days; } main() { int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; cout << day(y2, m2, d2) - day(y1, m1, d1) << endl; } }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-5; typedef long long ll; int uru(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); } int day(int y, int m, int d) { int days = 0; for (int i = 1; i <= y - 1; i++) days += uru(i) + 365; if (m > 1) days += 31; if (m > 2) days += 28 + uru(y); if (m > 3) days += 31; if (m > 4) days += 30; if (m > 5) days += 31; if (m > 6) days += 30; if (m > 7) days += 31; if (m > 8) days += 31; if (m > 9) days += 30; if (m > 10) days += 31; if (m > 11) days += 30; days += d - 1; return days; } main() { int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; cout << day(y2, m2, d2) - day(y1, m1, d1) << endl; } }
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
337
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; // int mm1[] = {0,31,59,90,120,151,181,212,242,273,303,334}; // int mm2[] = {0,31,60,91,121,152,182,213,243,274,304,335}; // ¼—ï‚P”N‚PŒŽ‚P“ú‚©‚ç‚Ì“ú” ll days(int y, int m, int d) { y--; ll res = y * 365; res += (y / 4) - (y / 100) + (y / 400); // ‰[”N for (int i = 1; i < m; i++) { res += 31; if (i == 4 || i == 6 || i == 9 || i == 11) res--; if (i == 2) { res -= 3; if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) res++; } } // if ( // ret += mm2[m-1]; // else // ret += mm1[m-1]; return res + d - 1; } int main() { int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (y1 < 0 || y2 < 0 || m1 < 0 || m2 < 0 || d1 < 0 || d2 < 0) break; cout << days(y2, m2, d2) - days(y1, m1, d1) << endl; } }
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; // ¼—ï‚P”N‚PŒŽ‚P“ú‚©‚ç‚Ì“ú” ll days(int y, int m, int d) { y--; ll res = y * 365; res += (y / 4) - (y / 100) + (y / 400); // ‰[”N for (int i = 1; i < m; i++) { res += 31; if (i == 4 || i == 6 || i == 9 || i == 11) res--; if (i == 2) { res -= 3; y++; if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) res++; } } return res + d - 1; } int main() { // int y,m,d; // while(cin>>y>>m>>d) { // cout << days(y,m,d) << endl; // } int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) { if (y1 < 0 || y2 < 0 || m1 < 0 || m2 < 0 || d1 < 0 || d2 < 0) break; cout << days(y2, m2, d2) - days(y1, m1, d1) << endl; } }
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
270
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool checkUru(const int y) { if (y == 0) return false; if (y % 4 == 0) { if (y % 100 == 0) { if (y % 400 == 0) { return true; } else { return false; } } else return true; } else return false; } typedef long long ll; const int md[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; ll calcDays(ll y, ll m, ll d) { ll sum = 0; for (ll i = 0; i < y; i++) { if (checkUru(i)) { sum += 366; } else sum += 365; } for (ll i = 1; i < m; i++) { if (checkUru(i) && m == 2) { sum += md[i] + 1; } else sum += md[i]; } sum += d; return sum; } int main() { ll y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2 && (y1 >= 0 && m1 >= 0 && d1 >= 0 && y2 >= 0 && m2 >= 0 && d2 >= 0)) { ll sum = calcDays(y2, m2, d2) - calcDays(y1, m1, d1); cout << sum << endl; // if(y1!=y2){ // for(int y = y1+1; y < y2; y++){ // if(checkUru(y)){ // sum+=366; // } // else // sum+=365; // } // // y1ツづ2ツづ可づつつ「ツづ計ツ算 // if(checkUru(y1)){ // sum+=(md[m1]-d1); // if(m1==2) // sum++; // for(int m=m1+1; m<=12; m++){ // if(m==2) // sum++; // sum+=md[m]; // } // } // else{ // sum+=(md[m1]-d1); // for(int m=m1+1; m<=12; m++){ // sum+=md[m]; // } // } // // if(checkUru(y2)){ // sum+=(d1); // for(int m=1; m<m2; m++){ // if(m==2) // sum++; // sum+=md[m]; // } // } // else{ // sum+=(d1); // for(int m=1; m<m2; m++){ // sum+=md[m]; // } // } //} // else{ // if(m1!=m2){ // for(int m=m1+1; m < m2; m++){ // if(checkUru(y1)&&m==2){ // sum+=29; // } // else // sum+=md[m]; // } // // m1ツづ2ツづ可づつつ「ツづ計ツ算 // if(checkUru(y1)&&m1==2){ // sum+=(md[m1]-d1)+1; // } // else // sum+=(md[m1]-d1); // // m2 // sum+=d2; // } // else{ // sum+=d2-d1; // } //} // cout<<sum<<endl; } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool checkUru(const int y) { // if(y%4==0&&y%100!=0){ // return true; //} // else if(y%400==0){ // return true; //} // else // return false; if (y == 0) return false; if (y % 4 == 0) { if (y % 100 == 0) { if (y % 400 == 0) { return true; } else { return false; } } else return true; } else return false; } typedef long long ll; const int md[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; ll calcDays(const ll y, const ll m, const ll d) { ll sum = 0; for (ll i = 0; i < y; i++) { if (checkUru(i)) { sum += 366; } else sum += 365; } for (ll i = 1; i < m; i++) { if (checkUru(y) && i == 2) { sum += md[i] + 1; } else sum += md[i]; } sum += d; return sum; } int main() { ll y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2 && (y1 >= 0 && m1 >= 0 && d1 >= 0 && y2 >= 0 && m2 >= 0 && d2 >= 0)) { ll sum = calcDays(y2, m2, d2) - calcDays(y1, m1, d1); cout << sum << endl; } return 0; }
[["+", 49, 53, 54, 55, 0, 56, 0, 153, 0, 154], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
377
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (;;) { int y[2], m[2], d[2]; for (int i = 0; i < 2; ++i) { cin >> y[i] >> m[i] >> d[i]; if (y[i] < 0 || m[i] < 0 || d[i] < 0) return 0; } long long sum[2] = {0}; for (int i = 0; i < 2; ++i) { for (int j = 1; j < y[i]; ++j) { sum[i] += 365; if (j % 400 == 0 || (j % 100 != 0 && j % 4 == 0)) ++sum[i]; } for (int j = 1; j < m[i]; ++j) { sum[i] += month[j]; if (j == 2 && (y[i] % 400 == 0 || (y[i] % 100 != 0 && y[i] % 4 == 0))) ++sum[i]; } sum[i] += d[i]; } cout << (sum[1] - sum[0]) << endl; } }
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (;;) { int y[2], m[2], d[2]; for (int i = 0; i < 2; ++i) { cin >> y[i] >> m[i] >> d[i]; if (y[i] < 0 || m[i] < 0 || d[i] < 0) return 0; } long long sum[2] = {0}; for (int i = 0; i < 2; ++i) { for (int j = 1; j < y[i]; ++j) { sum[i] += 365; if (j % 400 == 0 || (j % 100 != 0 && j % 4 == 0)) ++sum[i]; } for (int j = 1; j < m[i]; ++j) { sum[i] += month[j]; if (j == 2 && (y[i] % 400 == 0 || (y[i] % 100 != 0 && y[i] % 4 == 0))) ++sum[i]; } sum[i] += d[i]; } cout << (sum[1] - sum[0]) << endl; } }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21]]
1
334
#include <iostream> using namespace std; bool uru(int y) { if (!(y % 400)) return true; if (!(y % 100)) return false; if (!(y % 4)) return true; return false; } int day(int y, int m, int d) { int res = 0; int month[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30}; for (int i = 2000; i < y; i++) { if (uru(i)) res += 366; else res += 365; } for (int i = 0; i < m - 1; i++) res += month[i]; if (m > 2) { if (uru(y)) res += 29; else res += 28; } res += d; return res; } int main() { int y1, y2, m1, m2, d1, d2; while (1) { cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2; if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; int s1, s2; s1 = day(y1, m1, d1); s2 = day(y2, m2, d2); cout << s2 - s1 << endl; } }
#include <iostream> using namespace std; bool uru(int y) { if (!(y % 400)) return true; if (!(y % 100)) return false; if (!(y % 4)) return true; return false; } int day(int y, int m, int d) { int res = 0; int month[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30}; for (int i = 0; i < y; i++) { if (uru(i)) res += 366; else res += 365; } for (int i = 0; i < m - 1; i++) res += month[i]; if (m > 2) { if (uru(y)) res += 29; else res += 28; } res += d; return res; } int main() { int y1, y2, m1, m2, d1, d2; while (1) { cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2; if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break; int s1, s2; s1 = day(y1, m1, d1); s2 = day(y2, m2, d2); cout << s2 - s1 << endl; } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
289
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define all(v) (v).begin(), (v).end() #define rev(s) (s).rbegin(), (s).rend() #define MP make_pair #define X first #define Y second using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; int ytoi(int y) { return (y * 365 + y / 4 - y / 100 + y / 400); } int md[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int daycount(int y, int m, int d) { int res = 0; res += ytoi(y - 1); res += md[m - 1]; res += d; res += ((y % 4 == 0 || y % 100 || y % 400) && m >= 3); return res; } int main() { for (int i = 1; i <= 12; i++) md[i] += md[i - 1]; int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 >= 0) { cout << daycount(y2, m2, d2) - daycount(y1, m1, d1) << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define all(v) (v).begin(), (v).end() #define rev(s) (s).rbegin(), (s).rend() #define MP make_pair #define X first #define Y second using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; int ytoi(int y) { return (y * 365 + y / 4 - y / 100 + y / 400); } int md[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int daycount(int y, int m, int d) { int res = 0; res += ytoi(y - 1); res += md[m - 1]; res += d; res += (((y % 4 == 0 && y % 100) || y % 400 == 0) && m >= 3); return res; } int main() { for (int i = 1; i <= 12; i++) md[i] += md[i - 1]; int y1, m1, d1, y2, m2, d2; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 >= 0) { cout << daycount(y2, m2, d2) - daycount(y1, m1, d1) << endl; } return 0; }
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 106], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 98], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 13]]
1
316
#include <iostream> using namespace std; int fairfiled(int y, int m, int d) { if (m < 3) { --y; m += 12; } return 365 * y + (y / 4) - (y / 100) + (y / 400) + (206 * (m + 1) / 10) + d - 428; } int main() { int y1, m1, d1; int y2, m2, d2; int sum; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > 0) { cout << fairfiled(y2, m2, d2) - fairfiled(y1, m1, d1) << endl; } return 0; }
#include <iostream> using namespace std; int fairfiled(int y, int m, int d) { if (m < 3) { --y; m += 12; } return 365 * y + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1) / 10) + d - 428; } int main() { int y1, m1, d1; int y2, m2, d2; int sum; while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > 0) { cout << fairfiled(y2, m2, d2) - fairfiled(y1, m1, d1) << endl; } return 0; }
[["-", 31, 16, 12, 23, 0, 16, 31, 16, 31, 13], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 31, 13]]
1
144
def uru(y): return y % 4 == 0 and y % 100 != 0 or y % 400 == 0 def y_to_d(y): ret = 0 for i in range(y): if uru(i): ret += 366 else: ret += 365 return ret month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def m_to_d(y, m): m -= 1 ret = 0 for i in range(m-1): ret += month[i] if m >= 2 and uru: ret += 1 return ret while True: y1, m1, d1, y2, m2, d2 = map(int, input().split()) if min(y1, m1, d1, y2, m2, d2) < 0: quit() ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1 ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2 print(ymd2 - ymd1)
def uru(y): return y % 4 == 0 and y % 100 != 0 or y % 400 == 0 def y_to_d(y): ret = 0 for i in range(y): if uru(i): ret += 366 else: ret += 365 return ret month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def m_to_d(y, m): m -= 1 ret = 0 for i in range(m): ret += month[i] if m >= 2 and uru(y): ret += 1 return ret while True: y1, m1, d1, y2, m2, d2 = map(int, input().split()) if min(y1, m1, d1, y2, m2, d2) < 0: quit() ymd1 = y_to_d(y1) + m_to_d(y1, m1) + d1 ymd2 = y_to_d(y2) + m_to_d(y2, m2) + d2 print(ymd2 - ymd1)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 22], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 25]]
5
210
function NotOne(arr) { var cnt = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; arr.forEach(function(v) { cnt[(v - 0)]++; }); var bad = []; cnt.forEach(function(v, i) { if (v >= 2) bad.push(i); }); var result = []; arr.forEach(function(v, i) { if (bad.indexOf(v) != -1) result.push(i); }); return result; } var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = input.trim().split("\n"); var STR = ""; var n = Arr.shift() - 0; for (var I = 0; I < n; I++) { var yx = []; var YX = []; for (var i = 0; i < 9; i++) { var v = Arr.shift().split(" ").map(Number); yx.push(v); YX.push([ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]); } for (var i = 0; i < 9; i++) { var re = NotOne(yx[i]); re.forEach(function(v) { YX[i][v]++; }); } for (var i = 0; i < 9; i++) { var yy = []; for (var j = 0; j < 9; j++) yy.push(yx[j][i]); var re = NotOne(yy); re.forEach(function(v) { YX[v][i]++; }); } for (var y = 0; y < 3; y++) { for (var x = 0; x < 3; x++) { var i = y * 3; var j = x * 3; var z = [ [ 0 + i, 0 + j ], [ 0 + i, 1 + j ], [ 0 + i, 2 + j ], [ 1 + i, 0 + j ], [ 1 + i, 1 + j ], [ 1 + i, 2 + j ], [ 2 + i, 0 + j ], [ 2 + i, 1 + j ], [ 2 + i, 2 + j ] ]; var zz = []; z.forEach(function(v) { zz.push(yx[v[0]][v[1]]); }); var re = NotOne(zz); re.forEach(function(v) { YX[z[v][0]][z[v][1]]++; }); } } yx.forEach(function(V, i) { V.forEach(function(v, j) { yx[i][j] = (YX[i][j] >= 1) ? "*" + v : " " + v; }); }); STR += yx.join("\n").replace(/\,/g, "") + "\n"; } console.log(STR.trim());
function NotOne(arr) { var cnt = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; arr.forEach(function(v) { cnt[(v - 0)]++; }); var bad = []; cnt.forEach(function(v, i) { if (v >= 2) bad.push(i); }); var result = []; arr.forEach(function(v, i) { if (bad.indexOf(v) != -1) result.push(i); }); return result; } var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = input.trim().split("\n"); var STR = ""; var n = Arr.shift() - 0; for (var I = 0; I < n; I++) { var yx = []; var YX = []; for (var i = 0; i < 9; i++) { var v = Arr.shift().split(" ").map(Number); yx.push(v); YX.push([ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]); } for (var i = 0; i < 9; i++) { var re = NotOne(yx[i]); re.forEach(function(v) { YX[i][v]++; }); } for (var i = 0; i < 9; i++) { var yy = []; for (var j = 0; j < 9; j++) yy.push(yx[j][i]); var re = NotOne(yy); re.forEach(function(v) { YX[v][i]++; }); } for (var y = 0; y < 3; y++) { for (var x = 0; x < 3; x++) { var i = y * 3; var j = x * 3; var z = [ [ 0 + i, 0 + j ], [ 0 + i, 1 + j ], [ 0 + i, 2 + j ], [ 1 + i, 0 + j ], [ 1 + i, 1 + j ], [ 1 + i, 2 + j ], [ 2 + i, 0 + j ], [ 2 + i, 1 + j ], [ 2 + i, 2 + j ] ]; var zz = []; z.forEach(function(v) { zz.push(yx[v[0]][v[1]]); }); var re = NotOne(zz); re.forEach(function(v) { YX[z[v][0]][z[v][1]]++; }); } } yx.forEach(function(V, i) { V.forEach(function(v, j) { yx[i][j] = (YX[i][j] >= 1) ? "*" + v : " " + v; }); }); STR += yx.join("\n").replace(/\,/g, "") + "\n\n"; } console.log(STR.trim());
[["+", 0, 1, 0, 564, 12, 16, 12, 557, 0, 44]]
2
722
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-- > 0) { boolean[][] r = new boolean[9][9]; int[][] l = new int[9][9]; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { l[i][j] = sc.nextInt(); } } for (int i = 0; i < 9; i++) { int[] c1 = new int[10]; int[] c2 = new int[10]; int[] c3 = new int[10]; for (int j = 0; j < 9; j++) { if (++c1[l[i][j]] > 1) { r[i][j] = true; for (int k = j - 1; k >= 0; k--) { if (l[i][j] == l[i][k]) { r[i][k] = true; break; } } } if (++c2[l[j][i]] > 1) { r[j][i] = true; for (int k = j - 1; k >= 0; k--) { if (l[j][i] == l[k][i]) { r[k][i] = true; break; } } } int y = i / 3 * 3 + j / 3, x = i % 3 * 3 + j % 3; if (++c3[l[y][x]] > 1) { r[y][x] = true; for (int k = j - 1; k >= 0; k--) { int yk = i / 3 * 3 + k / 3, xk = i % 3 * 3 + k % 3; if (l[y][x] == l[yk][xk]) { r[yk][xk] = true; break; } } } } } for (int i = 0; i < 9; i++) { String s = ""; for (int j = 0; j < 9; j++) { s += (r[i][j] ? "*" : " ") + l[i][j]; } System.out.println(s); } if (n > 1) { System.out.println(); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-- > 0) { boolean[][] r = new boolean[9][9]; int[][] l = new int[9][9]; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { l[i][j] = sc.nextInt(); } } for (int i = 0; i < 9; i++) { int[] c1 = new int[10]; int[] c2 = new int[10]; int[] c3 = new int[10]; for (int j = 0; j < 9; j++) { if (++c1[l[i][j]] > 1) { r[i][j] = true; for (int k = j - 1; k >= 0; k--) { if (l[i][j] == l[i][k]) { r[i][k] = true; break; } } } if (++c2[l[j][i]] > 1) { r[j][i] = true; for (int k = j - 1; k >= 0; k--) { if (l[j][i] == l[k][i]) { r[k][i] = true; break; } } } int y = i / 3 * 3 + j / 3, x = i % 3 * 3 + j % 3; if (++c3[l[y][x]] > 1) { r[y][x] = true; for (int k = j - 1; k >= 0; k--) { int yk = i / 3 * 3 + k / 3, xk = i % 3 * 3 + k % 3; if (l[y][x] == l[yk][xk]) { r[yk][xk] = true; break; } } } } } for (int i = 0; i < 9; i++) { String s = ""; for (int j = 0; j < 9; j++) { s += (r[i][j] ? "*" : " ") + l[i][j]; } System.out.println(s); } if (n > 0) { System.out.println(); } } } }
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499]]
3
571
#include <stdio.h> int main(void) { int i, j, k; int board[9][9]; int n; char ans[10][10]; scanf("%d", &n); while (n--) { for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { scanf("%d", &board[i][j]); } } for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { ans[i][j] = ' '; } } for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { for (k = j + 1; k < 9; k++) { if (board[i][j] == board[i][k]) { ans[i][j] = '*'; ans[i][k] = '*'; } if (board[j][i] == board[k][i]) { ans[j][i] = '*'; ans[k][i] = '*'; } if (board[i % 3 * 3 + j / 3][j % 3 + i / 3 * 3] == board[i % 3 * 3 + k / 3][k % 3 + i / 3 * 3]) { ans[i % 3 * 3 + j / 3][j % 3 + i / 3 * 3] = '*'; ans[i % 3 * 3 + k / 3][k % 3 + i / 3 * 3] = '*'; } } } } /* for(i = 0;i < 9;i++){ for(j = 0;j < 9;j++){ printf(" %d",board[i%3*3+j/3][j%3+i/3*3]); if(j%3==2)puts(""); } puts(""); } puts(""); */ for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { printf("%c%d", ans[i][j], board[i][j]); } puts(""); } if (n != 1) puts(""); } return 0; }
#include <stdio.h> int main(void) { int i, j, k; int board[9][9]; int n; char ans[10][10]; scanf("%d", &n); while (n--) { for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { scanf("%d", &board[i][j]); } } for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { ans[i][j] = ' '; } } for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { for (k = j + 1; k < 9; k++) { if (board[i][j] == board[i][k]) { ans[i][j] = '*'; ans[i][k] = '*'; } if (board[j][i] == board[k][i]) { ans[j][i] = '*'; ans[k][i] = '*'; } if (board[i % 3 * 3 + j / 3][j % 3 + i / 3 * 3] == board[i % 3 * 3 + k / 3][k % 3 + i / 3 * 3]) { ans[i % 3 * 3 + j / 3][j % 3 + i / 3 * 3] = '*'; ans[i % 3 * 3 + k / 3][k % 3 + i / 3 * 3] = '*'; } } } } /* for(i = 0;i < 9;i++){ for(j = 0;j < 9;j++){ printf(" %d",board[i%3*3+j/3][j%3+i/3*3]); if(j%3==2)puts(""); } puts(""); } puts(""); */ for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { printf("%c%d", ans[i][j], board[i][j]); } puts(""); } if (n) puts(""); } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
460
#include <stdio.h> #include <string.h> int main(void) { int puzzle[9][9]; char flag[9][9]; int n; int i, j, k, l; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 9; j++) { for (k = 0; k < 9; k++) { scanf("%d", &puzzle[j][k]); } } memset(flag, ' ', sizeof(flag)); for (j = 0; j < 9; j++) { for (k = 0; k < 9 - 1; k++) { for (l = k + 1; l < 9; l++) { if (puzzle[j][k] == puzzle[j][l]) { flag[j][k] = flag[j][l] = '*'; } if (puzzle[k][j] == puzzle[l][j]) { flag[k][j] = flag[l][j] = '*'; } if (puzzle[j / 3 * 3 + k / 3][j % 3 * 3 + k % 3] == puzzle[j / 3 * 3 + l / 3][j % 3 * 3 + l % 3]) { flag[j / 3 * 3 + k / 3][j % 3 * 3 + k % 3] = flag[j / 3 * 3 + l / 3][j % 3 * 3 + l % 3] = '*'; } } } } if (i > 1) { printf("\n"); } for (j = 0; j < 9; j++) { for (k = 0; k < 9; k++) { printf("%c%d", flag[j][k], puzzle[j][k]); } printf("\n"); } } return (0); }
#include <stdio.h> #include <string.h> int main(void) { int puzzle[9][9]; char flag[9][9]; int n; int i, j, k, l; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 9; j++) { for (k = 0; k < 9; k++) { scanf("%d", &puzzle[j][k]); } } memset(flag, ' ', sizeof(flag)); for (j = 0; j < 9; j++) { for (k = 0; k < 9 - 1; k++) { for (l = k + 1; l < 9; l++) { if (puzzle[j][k] == puzzle[j][l]) { flag[j][k] = flag[j][l] = '*'; } if (puzzle[k][j] == puzzle[l][j]) { flag[k][j] = flag[l][j] = '*'; } if (puzzle[j / 3 * 3 + k / 3][j % 3 * 3 + k % 3] == puzzle[j / 3 * 3 + l / 3][j % 3 * 3 + l % 3]) { flag[j / 3 * 3 + k / 3][j % 3 * 3 + k % 3] = flag[j / 3 * 3 + l / 3][j % 3 * 3 + l % 3] = '*'; } } } } if (i >= 1) { printf("\n"); } for (j = 0; j < 9; j++) { for (k = 0; k < 9; k++) { printf("%c%d", flag[j][k], puzzle[j][k]); } printf("\n"); } } return (0); }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
439
m[9][9]; x[9][9]; z[10]; main(n, i, j) { for (scanf("%d", &n); n--; n > 1 ? puts("") : 1, memset(x, 0, 324)) { for (i = 0; i < 9; i++) for (j = 0; j < 9; j++) scanf("%d", m[i] + j); for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[i][j]]++; for (j = 0; j < 9; j++) if (z[m[i][j]] > 1) x[i][j] = 1; } for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[j][i]]++; for (j = 0; j < 9; j++) if (z[m[j][i]] > 1) x[j][i] = 1; } for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3]]++; for (j = 0; j < 9; j++) if (z[m[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3]] > 1) x[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3] = 1; } for (i = 0; i < 9; puts(""), i++) for (j = 0; j < 9; j++) printf(x[i][j] ? "*%d" : " %d", m[i][j]); } exit(0); }
m[9][9]; x[9][9]; z[10]; main(n, i, j) { for (scanf("%d", &n); n--; n ? puts("") : 1, memset(x, 0, 324)) { for (i = 0; i < 9; i++) for (j = 0; j < 9; j++) scanf("%d", m[i] + j); for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[i][j]]++; for (j = 0; j < 9; j++) if (z[m[i][j]] > 1) x[i][j] = 1; } for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[j][i]]++; for (j = 0; j < 9; j++) if (z[m[j][i]] > 1) x[j][i] = 1; } for (i = 0; i < 9; i++) { memset(z, 0, 40); for (j = 0; j < 9; j++) z[m[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3]]++; for (j = 0; j < 9; j++) if (z[m[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3]] > 1) x[i % 3 * 3 + j / 3][i / 3 * 3 + j % 3] = 1; } for (i = 0; i < 9; puts(""), i++) for (j = 0; j < 9; j++) printf(x[i][j] ? "*%d" : " %d", m[i][j]); } exit(0); }
[["-", 0, 7, 26, 34, 31, 41, 15, 16, 17, 47], ["-", 0, 7, 26, 34, 31, 41, 15, 16, 12, 13]]
0
483
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool ok[9][9]; int m[9][9]; void reset(int *r) { for (int i = 0; i < 10; ++i) *(r + i) = 0; } void func(int x, int y) { int cn[10] = {}; for (int i = x; i < x + 3; ++i) for (int j = y; j < y + 3; ++j) cn[m[i][j]]++; for (int i = x; i < x + 3; ++i) { for (int j = y; j < y + 3; ++j) { if (cn[m[i][j]] >= 2) ok[i][j] = true; } } } int main() { int n; cin >> n; for (int c = 0; c < n; ++c) { for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) ok[i][j] = false; for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) cin >> m[i][j]; int cnt[10] = {0}; for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) cnt[m[j][i]]++; for (int j = 0; j < 9; ++j) { if (cnt[m[j][i]] >= 2) ok[j][i] = true; } reset(cnt); } for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) cnt[m[i][j]]++; for (int j = 0; j < 9; ++j) { if (cnt[m[i][j]] >= 2) ok[i][j] = true; } reset(cnt); } for (int i = 0; i < 9; i += 3) for (int j = 0; j < 9; j += 3) func(i, j); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (ok[i][j]) cout << "#"; else cout << " "; cout << m[i][j]; } cout << endl; } if (c != n - 1) cout << endl; } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool ok[9][9]; int m[9][9]; void reset(int *r) { for (int i = 0; i < 10; ++i) *(r + i) = 0; } void func(int x, int y) { int cn[10] = {}; for (int i = x; i < x + 3; ++i) for (int j = y; j < y + 3; ++j) cn[m[i][j]]++; for (int i = x; i < x + 3; ++i) { for (int j = y; j < y + 3; ++j) { if (cn[m[i][j]] >= 2) ok[i][j] = true; } } } int main() { int n; cin >> n; for (int c = 0; c < n; ++c) { for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) ok[i][j] = false; for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) cin >> m[i][j]; int cnt[10] = {0}; for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) cnt[m[j][i]]++; for (int j = 0; j < 9; ++j) { if (cnt[m[j][i]] >= 2) ok[j][i] = true; } reset(cnt); } for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) cnt[m[i][j]]++; for (int j = 0; j < 9; ++j) { if (cnt[m[i][j]] >= 2) ok[i][j] = true; } reset(cnt); } for (int i = 0; i < 9; i += 3) for (int j = 0; j < 9; j += 3) func(i, j); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (ok[i][j]) cout << "*"; else cout << " "; cout << m[i][j]; } cout << endl; } if (c != n - 1) cout << endl; } return 0; }
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]]
1
597
#include <cstdio> using namespace std; int main() { int N; for (scanf("%d", &N); N--;) { char pz[9][12] = {}; char res[9][12] = {}; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { scanf(" %c", &pz[i][j]); } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { bool flg = true; for (int k = 0; k < 9; k++) { if (i == k) continue; if (pz[i][j] == pz[k][j]) flg = 0; } for (int k = 0; k < 9; k++) { if (j == k) continue; if (pz[i][j] == pz[i][k]) flg = 0; } int r = i / 3, c = j / 3; for (int k = 0; k < 3; k++) { for (int l = 0; k < 3; l++) { if (r + k == i && c + l == j) continue; if (pz[i][j] == pz[r + k][c + l]) flg = 0; } } if (flg) { res[i][j] = ' '; } else { res[i][j] = '*'; } } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { printf("%c", res[i][j]); printf("%c", pz[i][j]); } puts(""); } if (N >= 1) puts(""); } return 0; }
#include <cstdio> using namespace std; int main() { int N; for (scanf("%d", &N); N--;) { char pz[9][12] = {}; char res[9][12] = {}; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { scanf(" %c", &pz[i][j]); } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { bool flg = true; for (int k = 0; k < 9; k++) { if (i == k) continue; if (pz[i][j] == pz[k][j]) flg = 0; } for (int k = 0; k < 9; k++) { if (j == k) continue; if (pz[i][j] == pz[i][k]) flg = 0; } int r = i / 3 * 3, c = j / 3 * 3; for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { if (r + k == i && c + l == j) continue; if (pz[i][j] == pz[r + k][c + l]) flg = 0; } } if (flg) { res[i][j] = ' '; } else { res[i][j] = '*'; } } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { printf("%c", res[i][j]); printf("%c", pz[i][j]); } puts(""); } if (N >= 1) puts(""); } return 0; }
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22]]
1
437
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int main() { int N; cin >> N; while (N--) { int field[9][9]; for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { cin >> field[i][j]; } } vector<vector<int>> oks(9, vector<int>(9, true)); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 9; ++k) { if (j == k) continue; if (field[i][j] == field[i][k]) oks[i][j] = false; } for (int k = 0; k < 9; ++k) { if (i == k) continue; if (field[i][j] == field[k][j]) oks[i][j] = false; } int ax = j / 3; int ay = i / 3; for (int k = ax * 3; k < ax * 3 + 3; ++k) { for (int l = ay * 3; l < ay * 3 + 3; ++l) { if (k == j && l == i) continue; if (field[i][j] == field[l][k]) oks[i][j] = false; } } } } for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (oks[i][j]) cout << " "; else cout << "*"; cout << field[i][j]; } cout << endl; } if (N != 1) cout << endl; } return 0; }
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int main() { int N; cin >> N; while (N--) { int field[9][9]; for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { cin >> field[i][j]; } } vector<vector<int>> oks(9, vector<int>(9, true)); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 9; ++k) { if (j == k) continue; if (field[i][j] == field[i][k]) oks[i][j] = false; } for (int k = 0; k < 9; ++k) { if (i == k) continue; if (field[i][j] == field[k][j]) oks[i][j] = false; } int ax = j / 3; int ay = i / 3; for (int k = ax * 3; k < ax * 3 + 3; ++k) { for (int l = ay * 3; l < ay * 3 + 3; ++l) { if (k == j && l == i) continue; if (field[i][j] == field[l][k]) oks[i][j] = false; } } } } for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (oks[i][j]) cout << " "; else cout << "*"; cout << field[i][j]; } cout << endl; } if (N) cout << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
453
#include <iostream> using namespace std; int main() { int ms, ml; while (cin >> ms >> ml) { if (ms < 35.50) ms = 0; else if (ms < 37.50) ms = 1; else if (ms < 40.00) ms = 2; else if (ms < 43.00) ms = 3; else if (ms < 50.00) ms = 4; else if (ms < 55.00) ms = 5; else if (ms < 70.00) ms = 6; else ms = 7; if (ml < 71.00) ml = 0; else if (ml < 77.00) ml = 1; else if (ml < 83.00) ml = 2; else if (ml < 89.00) ml = 3; else if (ml < 105.00) ml = 4; else if (ml < 116.00) ml = 5; else if (ml < 148.00) ml = 6; else ml = 7; if (ms < ml) ms = ml; switch (ms) { case 0: cout << "AAA" << endl; break; case 1: cout << "AA" << endl; break; case 2: cout << "A" << endl; break; case 3: cout << "B" << endl; break; case 4: cout << "C" << endl; break; case 5: cout << "D" << endl; break; case 6: cout << "E" << endl; break; case 7: cout << "NA" << endl; break; } } return 0; }
#include <iostream> using namespace std; int main() { double ms, ml; while (cin >> ms >> ml) { if (ms < 35.50) ms = 0; else if (ms < 37.50) ms = 1; else if (ms < 40.00) ms = 2; else if (ms < 43.00) ms = 3; else if (ms < 50.00) ms = 4; else if (ms < 55.00) ms = 5; else if (ms < 70.00) ms = 6; else ms = 7; if (ml < 71.00) ml = 0; else if (ml < 77.00) ml = 1; else if (ml < 83.00) ml = 2; else if (ml < 89.00) ml = 3; else if (ml < 105.00) ml = 4; else if (ml < 116.00) ml = 5; else if (ml < 148.00) ml = 6; else ml = 7; if (ms < ml) ms = ml; switch ((int)ms) { case 0: cout << "AAA" << endl; break; case 1: cout << "AA" << endl; break; case 2: cout << "A" << endl; break; case 3: cout << "B" << endl; break; case 4: cout << "C" << endl; break; case 5: cout << "D" << endl; break; case 6: cout << "E" << endl; break; case 7: cout << "NA" << endl; break; } } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 99, 15, 339, 51, 74, 0, 24], ["+", 0, 99, 15, 339, 51, 74, 39, 77, 39, 40], ["+", 8, 9, 0, 99, 15, 339, 51, 74, 0, 25]]
1
312
#include <iostream> using namespace std; int main() { double ms, ml; double s[7] = {35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 70.00}; double l[7] = {71.00, 77.00, 83.00, 89.00, 105.00, 116.00, 148.00}; char r[7][4] = {"AAA", "AA", "A", "B", "C", "D", "NA"}; while (cin >> ms >> ml) { int ss = 6, ll = 6; for (int i = 6; i >= 0; i--) { if (ms < s[i]) { ss = i; } } for (int i = 6; i >= 0; i--) { if (ml < l[i]) { ll = i; } } if (ss < ll) { ss = ll; } cout << r[ss] << endl; } return 0; }
#include <iostream> using namespace std; int main() { double ms, ml; double s[7] = {35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 70.00}; double l[7] = {71.00, 77.00, 83.00, 89.00, 105.00, 116.00, 148.00}; char r[8][4] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; while (cin >> ms >> ml) { int ss = 7, ll = 7; for (int i = 6; i >= 0; i--) { if (ms < s[i]) { ss = i; } } for (int i = 6; i >= 0; i--) { if (ml < l[i]) { ll = i; } } if (ss < ll) { ss = ll; } cout << r[ss] << endl; } return 0; }
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 62], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
205
#include <iostream> using namespace std; int main(void) { double a, b; cin >> a >> b; if (a < 35.5 && b < 71.0) cout << "AAA" << endl; else if (a < 37.5 && b < 77.0) cout << "AA" << endl; else if (a < 40.0 && b < 83.0) cout << "A" << endl; else if (a < 43.0 && b < 89.0) cout << "B" << endl; else if (a < 50.0 && b < 105.0) cout << "C" << endl; else if (a < 55.0 && b < 116.0) cout << "D" << endl; else if (a < 70.0 && b < 148.0) cout << "E" << endl; else cout << "NA" << endl; return 0; }
#include <iostream> using namespace std; int main(void) { double a, b; while (cin >> a >> b) { if (a < 35.5 && b < 71.0) cout << "AAA" << endl; else if (a < 37.5 && b < 77.0) cout << "AA" << endl; else if (a < 40.0 && b < 83.0) cout << "A" << endl; else if (a < 43.0 && b < 89.0) cout << "B" << endl; else if (a < 50.0 && b < 105.0) cout << "C" << endl; else if (a < 55.0 && b < 116.0) cout << "D" << endl; else if (a < 70.0 && b < 148.0) cout << "E" << endl; else cout << "NA" << endl; } return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
168
#include <algorithm> #include <iostream> #include <string> using namespace std; #define MAX_CLASS 8 int check(double m, int type); int main() { double m500, m1000; string cls[MAX_CLASS] = {"AAA", "AA", "A", "B", "C", "D", "D", "NA"}; while (cin >> m500 >> m1000) { cout << cls[max(check(m500, 0), check(m1000, 1))] << endl; } return 0; } int check(double m, int type) { double dx[2][MAX_CLASS] = {{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0}, {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0}}; int ret = 7; for (int i = 0; i < MAX_CLASS - 1; i++) { if (m < dx[type][i]) { ret = i; break; } } return ret; }
#include <algorithm> #include <iostream> #include <string> using namespace std; #define MAX_CLASS 8 int check(double m, int type); int main() { double m500, m1000; string cls[MAX_CLASS] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; while (cin >> m500 >> m1000) { cout << cls[max(check(m500, 0), check(m1000, 1))] << endl; } return 0; } int check(double m, int type) { double dx[2][MAX_CLASS - 1] = {{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0}, {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0}}; int ret = 7; for (int i = 0; i < MAX_CLASS - 1; i++) { if (m < dx[type][i]) { ret = i; break; } } return ret; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 49, 80, 81, 16, 17, 33], ["+", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13]]
1
211
#include <cstdio> #include <string> main() { using namespace std; int i, j; string lv[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; double lvd5[7] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0}; int lvd1[7] = {71, 77, 83, 89, 105, 116, 148}; double ind1, ind2; while (~scanf("%lf %lf", &ind1, &ind2)) { i = j = 0; while (i < 7) { if (ind1 < lvd5[i]) break; i++; } while (j < 7) { if (ind2 < lvd1[j]) break; j++; } printf("%s\n", i <= j ? lv[i].c_str() : lv[j].c_str()); } return 0; }
#include <cstdio> #include <string> main() { using namespace std; int i, j; string lv[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; double lvd5[7] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0}; int lvd1[7] = {71, 77, 83, 89, 105, 116, 148}; double ind1, ind2; while (~scanf("%lf %lf", &ind1, &ind2)) { i = j = 0; while (i < 7) { if (ind1 < lvd5[i]) break; i++; } while (j < 7) { if (ind2 < lvd1[j]) break; j++; } printf("%s\n", i <= j ? lv[j].c_str() : lv[i].c_str()); } return 0; }
[["-", 64, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 64, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["-", 75, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 75, 2, 63, 118, 28, 69, 341, 342, 0, 22]]
1
208
#include <iostream> using namespace std; int main() { double time500, time1000; while (cin >> time500 >> time1000) { if (time500 < 35.5 && time1000 < 71.0) cout << "AAA" << endl; else if (time500 < 37.5 && time1000 < 77.0) cout << "AA" << endl; else if (time500 < 40.0 && time1000 < 83.0) cout << 'A' << endl; else if (time500 < 43.0 && time1000 < 89.0) cout << 'B' << endl; else if (time500 < 50.0 && time1000 < 105.0) cout << 'C' << endl; else if (time500 < 55.0 && time1000 < 116.0) cout << 'D' << endl; else if (time500 < 70.0 && time1000 < 28.0) cout << 'E' << endl; else cout << "NA" << endl; } return 0; }
#include <iostream> using namespace std; int main() { double time500, time1000; while (cin >> time500 >> time1000) { if (time500 < 35.5 && time1000 < 71.0) cout << "AAA" << endl; else if (time500 < 37.5 && time1000 < 77.0) cout << "AA" << endl; else if (time500 < 40.0 && time1000 < 83.0) cout << 'A' << endl; else if (time500 < 43.0 && time1000 < 89.0) cout << 'B' << endl; else if (time500 < 50.0 && time1000 < 105.0) cout << 'C' << endl; else if (time500 < 55.0 && time1000 < 116.0) cout << 'D' << endl; else if (time500 < 70.0 && time1000 < 148.0) cout << 'E' << endl; else cout << "NA" << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
171
#include <iostream> using namespace std; int main() { double f, s; while (cin >> f >> s) { if (f < 35 && s < 71) cout << "AAA"; else if (f < 37.5 && s < 77.0) cout << "AA"; else if (f < 40.5 && s < 83.0) cout << "A"; else if (f < 43.0 && s < 89.0) cout << "B"; else if (f < 50.0 && s < 105.0) cout << "C"; else if (f < 55.0 && s < 116.0) cout << "D"; else if (f < 70.0 && s < 148.0) cout << "E"; else cout << "NA"; cout << endl; } return 0; }
#include <iostream> using namespace std; int main() { double f, s; while (cin >> f >> s) { if (f < 35.5 && s < 71) cout << "AAA"; else if (f < 37.5 && s < 77.0) cout << "AA"; else if (f < 40.0 && s < 83.0) cout << "A"; else if (f < 43.0 && s < 89.0) cout << "B"; else if (f < 50.0 && s < 105.0) cout << "C"; else if (f < 55.0 && s < 116.0) cout << "D"; else if (f < 70.0 && s < 148.0) cout << "E"; else cout << "NA"; cout << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
159
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <stack> #include <string> #include <strstream> #include <vector> using namespace std; int main() { float a, b; cin >> a >> b; if (a < 35.5 && b < 71) puts("AAA"); else if (a < 37.5 && b < 77) puts("AA"); else if (a < 40 && b < 83) puts("A"); else if (a < 43 && b < 89) puts("B"); else if (a < 50 && b < 105) puts("C"); else if (a < 55 && b < 116) puts("D"); else if (a < 70 && b < 148) puts("E"); else puts("NA"); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <stack> #include <string> #include <strstream> #include <vector> using namespace std; int main() { float a, b; while (cin >> a >> b) { if (a < 35.5 && b < 71) puts("AAA"); else if (a < 37.5 && b < 77) puts("AA"); else if (a < 40 && b < 83) puts("A"); else if (a < 43 && b < 89) puts("B"); else if (a < 50 && b < 105) puts("C"); else if (a < 55 && b < 116) puts("D"); else if (a < 70 && b < 148) puts("E"); else puts("NA"); } return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
177
#include <iostream> using namespace std; int main() { double a, b; double A[] = {35.50, 37.50, 40.00, 43.00, 50.00, 55.00}; double B[] = {71, 77, 83, 89, 105, 116, 148}; string C[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; while (cin >> a >> b) { int i; for (i = 0; i < 7; i++) { if (a < A[i] && b < B[i]) { break; } } cout << C[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { double a, b; double A[] = {35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 70.00}; double B[] = {71, 77, 83, 89, 105, 116, 148}; string C[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"}; while (cin >> a >> b) { int i; for (i = 0; i < 7; i++) { if (a < A[i] && b < B[i]) { break; } } cout << C[i] << endl; } return 0; }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
156
# -*- coding:utf-8 -*- import sys t = [ {"name":"AAA","a":35.5,"b":71.0}, {"name":"AA" ,"a":37.5,"b":77.0}, {"name":"A" ,"a":40.0,"b":83.0}, {"name":"B" ,"a":43.0,"b":89.0}, {"name":"C" ,"a":50.0,"b":105.0}, {"name":"D" ,"a":55.0,"b":116.0}, {"name":"E" ,"a":70.5,"b":148.0}, ] while True: s = sys.stdin.readline() if not s: break a, b = [ float(x) for x in s.split() ] f = [ x for x in t if x["a"] > a and x["b"] > b ] if len(f) == 0 : print("NA") else: print(f[0]["name"])
# -*- coding:utf-8 -*- import sys t = [ {"name":"AAA","a":35.5,"b":71.0}, {"name":"AA" ,"a":37.5,"b":77.0}, {"name":"A" ,"a":40.0,"b":83.0}, {"name":"B" ,"a":43.0,"b":89.0}, {"name":"C" ,"a":50.0,"b":105.0}, {"name":"D" ,"a":55.0,"b":116.0}, {"name":"E" ,"a":70.0,"b":148.0}, ] while True: s = sys.stdin.readline() if not s: break a, b = [ float(x) for x in s.split() ] f = [ x for x in t if x["a"] > a and x["b"] > b ] if len(f) == 0 : print("NA") else: print(f[0]["name"])
[["-", 0, 662, 12, 634, 0, 680, 0, 569, 51, 531], ["+", 0, 662, 12, 634, 0, 680, 0, 569, 51, 531]]
5
251
ans = [] while True: lst = [] try: lst = input().split() except EOFError: break lst[0] = float(lst[0]) lst[1] = float(lst[1]) if lst[0] < 35.5 and lst[1] < 71.0: ans.append("AAA") elif lst[0] < 37.5 and lst[1] < 77.0: ans.append("AA") elif lst[0] < 40.5 and lst[1] < 83.0: ans.append("A") elif lst[0] < 43.0 and lst[1] < 89.0: ans.append("B") elif lst[0] < 50.0 and lst[1] < 105.0: ans.append("C") elif lst[0] < 55.0 and lst[1] < 116.0: ans.append("D") elif lst[0] < 70.0 and lst[1] < 148.0: ans.append("E") else: ans.append("NA") for i in ans: print(i)
ans = [] while True: lst = [] try: lst = input().split() except EOFError: break lst[0] = float(lst[0]) lst[1] = float(lst[1]) if lst[0] < 35.5 and lst[1] < 71.0: ans.append("AAA") elif lst[0] < 37.5 and lst[1] < 77.0: ans.append("AA") elif lst[0] < 40.0 and lst[1] < 83.0: ans.append("A") elif lst[0] < 43.0 and lst[1] < 89.0: ans.append("B") elif lst[0] < 50.0 and lst[1] < 105.0: ans.append("C") elif lst[0] < 55.0 and lst[1] < 116.0: ans.append("D") elif lst[0] < 70.0 and lst[1] < 148.0: ans.append("E") else: ans.append("NA") for i in ans: print(i)
[["-", 0, 57, 75, 665, 15, 679, 31, 666, 0, 531], ["+", 0, 57, 75, 665, 15, 679, 31, 666, 0, 531]]
5
230
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var I = 0; while (true) { var n = Arr.shift() - 0; if (n == 0) break; if (I != 0) console.log("\n"); I++; var rank = []; for (var i = 0; i < n; i++) { var arr = (Arr.shift()).split(" "); var score = (3 * (arr[1] - 0)) + (arr[3] - 0) + ((10 - i) * 0.01); rank.push([ arr[0], score ]); } rank.sort(function(a, b) { a = a[1]; b = b[1]; return b - a; }); rank.forEach(function(v) { console.log(v[0] + "," + Math.floor(v[1])); }); }
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var I = 0; while (true) { var n = Arr.shift() - 0; if (n == 0) break; if (I != 0) console.log(""); I++; var rank = []; for (var i = 0; i < n; i++) { var arr = (Arr.shift()).split(" "); var score = (3 * (arr[1] - 0)) + (arr[3] - 0) + ((10 - i) * 0.01); rank.push([ arr[0], score ]); } rank.sort(function(a, b) { a = a[1]; b = b[1]; return b - a; }); rank.forEach(function(v) { console.log(v[0] + "," + Math.floor(v[1])); }); }
[["-", 64, 1, 0, 2, 3, 3, 0, 557, 0, 44]]
2
245
import java.util.Arrays; import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); boolean first = true; for (;;) { int N = cin.nextInt(); if (N == 0) { break; } if (first) { first = false; } else { System.out.println(); } Team t[] = new Team[N]; for (int i = 0; i < N; i++) { String s = cin.next(); int a = cin.nextInt(); int b = cin.nextInt(); int c = cin.nextInt(); t[i] = new Team(s, i, a, b, c); } Arrays.sort(t); for (int i = N - 1; i >= 0; i--) { System.out.println(t[i].name + "," + t[i].total); } } } } class Team implements Comparable { String name; int num; int win; int lose; int drow; int total; Team(String s, int a, int b, int c, int d) { name = s; num = a; win = b; lose = c; drow = d; total = b * 3 + drow; } public int compareTo(Object o) { Team t = (Team)o; if (this.total == t.total) { return this.num - t.num; } else { return this.total - t.total; } } }
import java.util.Arrays; import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); boolean first = true; for (;;) { int N = cin.nextInt(); if (N == 0) { break; } if (first) { first = false; } else { System.out.println(); } Team t[] = new Team[N]; for (int i = 0; i < N; i++) { String s = cin.next(); int a = cin.nextInt(); int b = cin.nextInt(); int c = cin.nextInt(); t[i] = new Team(s, i, a, b, c); } Arrays.sort(t); for (int i = N - 1; i >= 0; i--) { System.out.println(t[i].name + "," + t[i].total); } } } } class Team implements Comparable { String name; int num; int win; int lose; int drow; int total; Team(String s, int a, int b, int c, int d) { name = s; num = a; win = b; lose = c; drow = d; total = b * 3 + drow; } public int compareTo(Object o) { Team t = (Team)o; if (this.total == t.total) { return t.num - this.num; } else { return this.total - t.total; } } }
[["-", 64, 196, 0, 37, 0, 16, 31, 509, 500, 274], ["+", 64, 196, 0, 37, 0, 16, 31, 509, 500, 22], ["-", 64, 196, 0, 37, 0, 16, 12, 509, 500, 22], ["+", 64, 196, 0, 37, 0, 16, 12, 509, 500, 274]]
3
348
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] param = new String[10]; do { for (int i = 0; i < n; i++) { String name = in.next(); int point = in.nextInt() * 3; in.next(); point += in.nextInt(); param[i] = String.format("%1$02d%2$02d%3$s,%4$d", point, i, name, point); } Arrays.sort(param, 0, n); for (int i = 0; i < n; i++) { System.out.println(param[i].substring(4)); } if ((n = in.nextInt()) == 0) { break; } else { System.out.println(); } } while (true); } }
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] param = new String[10]; do { for (int i = 0; i < n; i++) { String name = in.next(); int point = in.nextInt() * 3; in.next(); point += in.nextInt(); param[i] = String.format("%1$02d%2$02d%3$s,%4$d", 30 - point, i, name, point); } Arrays.sort(param, 0, n); for (int i = 0; i < n; i++) { System.out.println(param[i].substring(4)); } if ((n = in.nextInt()) == 0) { break; } else { System.out.println(); } } while (true); } }
[["+", 0, 11, 12, 492, 3, 4, 0, 16, 31, 499], ["+", 0, 11, 12, 492, 3, 4, 0, 16, 17, 33]]
3
215
#include <stdio.h>/*-1-0024 メンドくて放置&#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;(’ω’)&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602;うわああああああ*/ int main(void) { int a[10 + 1], b[10 + 1], c[10 + 1], ten[10 + 1], i, j, n, max, cnt; char moziretsu[20 + 1][10 + 1]; cnt = 0; scanf("%d", &n); while (n != 0) { if (0 < cnt) { printf("\n"); } for (i = 0; i < n; i++) { scanf("%s %d %d %d", moziretsu[i], &a[i], &b[i], &c[i]); ten[i] = a[i] * 3 + b[i] * 0 + c[i] * 1; } for (j = 0; j < n; j++) { max = -1; for (i = 0; i < n; i++) { if (max < ten[i]) { max = ten[i]; } } for (i = 0; i < n; i++) { if (max == ten[i]) { printf("%s,%d\n", moziretsu[i], ten[i]); ten[i] = -2; } } } cnt++; scanf("%d", &n); } return 0; }
#include <stdio.h> int main(void) { int a[10 + 1], b[10 + 1], c[10 + 1], ten[10 + 1], i, j, n, max, cnt; char moziretsu[10 + 1][20 + 1]; cnt = 0; scanf("%d", &n); while (n != 0) { if (0 < cnt) { printf("\n"); } for (i = 0; i < n; i++) { scanf("%s %d %d %d", moziretsu[i], &a[i], &b[i], &c[i]); ten[i] = a[i] * 3 + b[i] * 0 + c[i] * 1; } for (j = 0; j < n; j++) { max = -1; for (i = 0; i < n; i++) { if (max < ten[i]) { max = ten[i]; } } for (i = 0; i < n; i++) { if (max == ten[i]) { printf("%s,%d\n", moziretsu[i], ten[i]); ten[i] = -2; } } } cnt++; scanf("%d", &n); } return 0; }
[["-", 0, 43, 49, 80, 49, 80, 81, 16, 31, 13], ["+", 0, 43, 49, 80, 49, 80, 81, 16, 31, 13], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 31, 13], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 31, 13]]
0
289
#include <stdio.h> #include <string.h> int main(void) { int w, l, d; int n; int i, j, temp; int p[11]; char t[11][21], tempt[21]; scanf("%d", &n); while (n != 0) { for (i = 0; i < n; i++) { scanf("%s %d %d %d", t[i], &w, &l, &d); p[i] = w * 3 + d; } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (p[j - 1] < p[j]) { temp = p[j - 1]; p[j - 1] = p[j]; p[j] = temp; strcpy(tempt, t[j - 1]); strcpy(t[j - 1], t[j]); strcpy(t[j], tempt); } } } for (i = 0; i < n; i++) { printf("%s,%d\n", t[i], p[i]); } scanf("%d", &n); if (n != 0) { printf("\n"); } } return 0; }
#include <stdio.h> #include <string.h> int main(void) { int w, l, d; int n; int i, j, temp; int p[11]; char t[11][21], tempt[21]; scanf("%d", &n); while (n != 0) { for (i = 0; i < n; i++) { scanf("%s %d %d %d", t[i], &w, &l, &d); p[i] = w * 3 + d; } for (i = 0; i < n - 1; i++) { for (j = n - 1; j > i; j--) { if (p[j - 1] < p[j]) { temp = p[j - 1]; p[j - 1] = p[j]; p[j] = temp; strcpy(tempt, t[j - 1]); strcpy(t[j - 1], t[j]); strcpy(t[j], tempt); } } } for (i = 0; i < n; i++) { printf("%s,%d\n", t[i], p[i]); } scanf("%d", &n); if (n != 0) { printf("\n"); } } return 0; }
[["-", 8, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 33], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 17, 68]]
0
289
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Team { string name; int id; int point; bool operator<(const Team &r) const { return point == r.point ? id < r.id : point > r.point; } }; int main() { string name; int n, a, b, c, i = 0; while (cin >> n, n) { if (i) cout << endl; vector<Team> v(10); for (i = 0; i < n; i++) { cin >> name >> a >> b >> c; v[i].id = i; v[i].name = name; v[i].point = a * 3 + c; } sort(v.begin(), v.end()); for (i = 0; i < n; i++) { cout << v[i].name << "," << v[i].point << endl; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Team { string name; int id; int point; bool operator<(const Team &r) const { return point == r.point ? id < r.id : point > r.point; } }; int main() { string name; int n, a, b, c, i = 0; while (cin >> n, n) { if (i) cout << endl; vector<Team> v(n); for (i = 0; i < n; i++) { cin >> name >> a >> b >> c; v[i].id = i; v[i].name = name; v[i].point = a * 3 + c; } sort(v.begin(), v.end()); for (i = 0; i < n; i++) { cout << v[i].name << "," << v[i].point << endl; } } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
215
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define mp make_pair using namespace std; struct Team { int point; int num; string name; bool operator<(const Team &t) const { return point == t.point ? num < t.num : point < t.point; } }; int main() { int n; bool fisrt = true; while (cin >> n && n) { if (fisrt) { fisrt = false; } else { cout << endl; } priority_queue<Team> q; string s; int a, b, c; rep(i, n) { cin >> s >> a >> b >> c; Team t; t.point = 3 * a + c; t.num = 9; t.name = s; q.push(t); } rep(i, n) { cout << q.top().point << "," << q.top().name << endl; q.pop(); } } return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define mp make_pair using namespace std; struct Team { int point; int num; string name; bool operator<(const Team &t) const { return point == t.point ? num < t.num : point < t.point; } }; int main() { int n; bool fisrt = true; while (cin >> n && n) { if (fisrt) { fisrt = false; } else { cout << endl; } priority_queue<Team> q; string s; int a, b, c; rep(i, n) { cin >> s >> a >> b >> c; Team t; t.point = 3 * a + c; t.num = n - i; t.name = s; q.push(t); } rep(i, n) { cout << q.top().name << "," << q.top().point << endl; q.pop(); } } return 0; }
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["+", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120]]
1
218
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> //#include <utility> //#include <memory> //#include <functional> //#include <deque> //#include <cctype> //#include <ctime> //#include <numeric> //#include <list> //#include <iomanip> //#if __cplusplus >= 201103L //#include <array> //#include <tuple> //#include <initializer_list> //#include <forward_list> // //#define cauto const auto& //#else //#endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typedef vector<vector<long long>> vvll, vvLL; #define VV(T) vector<vector<T>> template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define reep(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) reep((i), 0, (n)) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(), (v).rend() #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) void mainmain() { int n; bool first = true; while (cin >> n, n) { if (!first) cout << endl; first = false; vector<pair<pii, string>> v(n); rep(i, n) { string s; cin >> s; int a, b, c; cin >> a >> b >> c; v[i] = mkp(pii(-a * 3 - c, -i), s); } sort(ALL(v)); rep(i, n) { cout << v[i].S << "," << -v[i].F.F << endl; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); mainmain(); }
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> //#include <utility> //#include <memory> //#include <functional> //#include <deque> //#include <cctype> //#include <ctime> //#include <numeric> //#include <list> //#include <iomanip> //#if __cplusplus >= 201103L //#include <array> //#include <tuple> //#include <initializer_list> //#include <forward_list> // //#define cauto const auto& //#else //#endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typedef vector<vector<long long>> vvll, vvLL; #define VV(T) vector<vector<T>> template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define reep(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) reep((i), 0, (n)) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(), (v).rend() #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) void mainmain() { int n; bool first = true; while (cin >> n, n) { if (!first) cout << endl; first = false; vector<pair<pii, string>> v(n); rep(i, n) { string s; cin >> s; int a, b, c; cin >> a >> b >> c; v[i] = mkp(pii(-a * 3 - c, i), s); } sort(ALL(v)); rep(i, n) { cout << v[i].S << "," << -v[i].F.F << endl; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); mainmain(); }
[["-", 3, 4, 0, 2, 3, 4, 0, 91, 17, 33]]
1
507
#include <iostream> #include <map> using namespace std; int main() { int n, p = 0; while (cin >> n, n) { multimap<int, string, greater<int>> m; if (p) cout << endl; p++; while (n--) { string s; int a, b, c; cin >> s >> a >> b >> c; a = a * 3 + c; m.insert(make_pair(a, s)); } for (multimap<int, string, greater<int>>::iterator it = m.begin(); it != m.end(); it++) { cout << (*it).second << ' ' << (*it).first << endl; } } }
#include <iostream> #include <map> using namespace std; int main() { int n, p = 0; while (cin >> n, n) { multimap<int, string, greater<int>> m; if (p) cout << endl; p++; while (n--) { string s; int a, b, c; cin >> s >> a >> b >> c; a = a * 3 + c; m.insert(make_pair(a, s)); } for (multimap<int, string, greater<int>>::iterator it = m.begin(); it != m.end(); it++) { cout << (*it).second << ',' << (*it).first << endl; } } }
[["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125]]
1
160
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; \ } #define dumpc(o) \ if (DBG) { \ cerr << #o; \ for (auto &e : (o)) \ cerr << " " << e; \ cerr << endl; \ } #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++) #define all(c) c.begin(), c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); class Team { public: string name; int score; bool operator<(const Team &other) { return this->score > other.score; } bool operator>(const Team &other) { return other.score < this->score; } Team(string s, int x) { this->name = s; this->score = x; } }; signed main() { int n, cnt(0); while (cin >> n, n) { vector<Team> team; rep(i, 0, n) { string s; int w, l, d; cin >> s >> w >> l >> d; Team a(s, w * 3 + d); team.push_back(a); } sort(team.begin(), team.end()); if (cnt++) cout << endl; each(it, team) cout << it->name << " " << it->score << endl; } return 0; }
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; \ } #define dumpc(o) \ if (DBG) { \ cerr << #o; \ for (auto &e : (o)) \ cerr << " " << e; \ cerr << endl; \ } #define rep(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--) #define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++) #define all(c) c.begin(), c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); class Team { public: string name; int score; bool operator<(const Team &other) { return this->score > other.score; } bool operator>(const Team &other) { return other.score < this->score; } Team(string s, int x) { this->name = s; this->score = x; } }; signed main() { int n, cnt(0); while (cin >> n, n) { vector<Team> team; rep(i, 0, n) { string s; int w, l, d; cin >> s >> w >> l >> d; Team a(s, w * 3 + d); team.push_back(a); } sort(team.begin(), team.end()); if (cnt++) cout << endl; each(it, team) cout << it->name << "," << it->score << endl; } return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
298
#include <iostream> using namespace std; typedef struct { string name; int score; } Team; int main(void) { int n; bool firstFlg = true; while (cin >> n && n) { if (!firstFlg) cout << endl; else firstFlg = false; Team t[n]; for (int i = 0; i < n; i++) { int win, lose, draw; cin >> t[i].name >> win >> lose >> draw; t[i].score = win * 3 + draw; } for (int i = 0; i < n - 1; i++) { for (int j = i; j < n - 1; j++) { if (t[j].score < t[j + 1].score) { Team tmp = t[j]; t[j] = t[j + 1]; t[j + 1] = tmp; } } } for (int i = 0; i < n; i++) { cout << t[i].name << "," << t[i].score << endl; } } return 0; }
#include <iostream> using namespace std; typedef struct { string name; int score; } Team; int main(void) { int n; bool firstFlg = true; while (cin >> n && n) { if (!firstFlg) cout << endl; else firstFlg = false; Team t[n]; for (int i = 0; i < n; i++) { int win, lose, draw; cin >> t[i].name >> win >> lose >> draw; t[i].score = win * 3 + draw; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (t[j].score < t[j + 1].score) { Team tmp = t[j]; t[j] = t[j + 1]; t[j + 1] = tmp; } } } for (int i = 0; i < n; i++) { cout << t[i].name << "," << t[i].score << endl; } } return 0; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
240
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { bool first = true; for (;;) { int n; cin >> n; if (n == 0) return 0; vector<pair<pair<int, int>, string>> score(n); for (int i = 0; i < n; ++i) { int a, b, c; cin >> score[i].second >> a >> b >> c; score[i].first.first = 3 * a + c; score[i].first.second = i; } sort(score.rbegin(), score.rend()); if (first) first = false; else cout << endl; for (int i = 0; i < n; ++i) { cout << score[i].second << ',' << score[i].first.first << endl; } } }
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { bool first = true; for (;;) { int n; cin >> n; if (n == 0) return 0; vector<pair<pair<int, int>, string>> score(n); for (int i = 0; i < n; ++i) { int a, b, c; cin >> score[i].second >> a >> b >> c; score[i].first.first = 3 * a + c; score[i].first.second = n - i; } sort(score.rbegin(), score.rend()); if (first) first = false; else cout << endl; for (int i = 0; i < n; ++i) { cout << score[i].second << ',' << score[i].first.first << endl; } } }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
1
221
#include <algorithm> #include <functional> #include <iostream> #include <iterator> #include <list> #include <map> #include <string> #include <vector> using namespace std; bool cmp(pair<int, string> a, pair<int, string> b) { return a.first > b.first; } int main(void) { bool b = false; while (1) { int a, n; string s; multimap<int, string, greater<int>> P; int w, d, l; cin >> n; if (n == 0) break; if (b == true) cout << endl; b = true; for (a = 0; a < n; a++) { cin >> s >> w >> l >> d; P.insert(pair<int, string>(w * 3 + d, s)); } multimap<int, string, greater<int>>::iterator it = P.begin(); while (it != P.end()) { cout << (*it).first << "," << (*it).second << endl; ++it; } } return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <iterator> #include <list> #include <map> #include <string> #include <vector> using namespace std; bool cmp(pair<int, string> a, pair<int, string> b) { return a.first > b.first; } int main(void) { bool b = false; while (1) { int a, n; string s; multimap<int, string, greater<int>> P; int w, d, l; cin >> n; if (n == 0) break; if (b == true) cout << endl; b = true; for (a = 0; a < n; a++) { cin >> s >> w >> l >> d; P.insert(pair<int, string>(w * 3 + d, s)); } multimap<int, string, greater<int>>::iterator it = P.begin(); while (it != P.end()) { cout << (*it).second << "," << (*it).first << endl; ++it; } } return 0; }
[["-", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["+", 31, 16, 31, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 0, 1, 0, 16, 31, 16, 12, 118, 119, 120]]
1
229
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int n, d = 0; while (cin >> n, n) { if (!d) cout << endl; int a, b, c, z[100], tmp; string s[100], tmp2; for (int i = 0; i < n; i++) { cin >> s[i] >> a >> b >> c; z[i] = a * 3 + c; } for (int i = 0; i < n - 1; i++) { for (int j = n - 1; j > i; j--) { if (z[j] > z[j - 1]) { tmp = z[j]; z[j] = z[j - 1]; z[j - 1] = tmp; tmp2 = s[j]; s[j] = s[j - 1]; s[j - 1] = tmp2; } } } for (int i = 0; i < n; i++) cout << s[i] << "," << z[i] << endl; d = 1; } }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int n, d = 0; while (cin >> n, n) { if (d) cout << endl; int a, b, c, z[100], tmp; string s[100], tmp2; for (int i = 0; i < n; i++) { cin >> s[i] >> a >> b >> c; z[i] = a * 3 + c; } for (int i = 0; i < n - 1; i++) { for (int j = n - 1; j > i; j--) { if (z[j] > z[j - 1]) { tmp = z[j]; z[j] = z[j - 1]; z[j - 1] = tmp; tmp2 = s[j]; s[j] = s[j - 1]; s[j - 1] = tmp2; } } } for (int i = 0; i < n; i++) cout << s[i] << "," << z[i] << endl; d = 1; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
1
248
#include <iostream> #include <map> #include <queue> #include <string> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define INF 114514810 #define ELEM(array) (sizeof(array) / sizeof *(array)) #define MAX_N 100 typedef unsigned int UINT; typedef long long ll; char num; string str; int main() { map<string, int> used; queue<string> zero; zero.push("01234567"); while (!zero.empty()) { string tmp; tmp = zero.front(); zero.pop(); int posi_zero = tmp.find("0"); if (0 == tmp.find("0")) { int dx[] = {1, 4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[0], tmp1[dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 1 || posi_zero == 2) { int dx[] = {-1, 1, 4}; REP(i, 3) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 3) { int dx[] = {-1, 4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 4) { int dx[] = {1, -4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 5 || posi_zero == 6) { int dx[] = {-1, 1, -4}; REP(i, 3) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 7) { int dx[] = {-1, -4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } } while (cin >> num) { str.push_back(num); REP(i, 7) { cin >> num; str.push_back(num); } cout << used[str] << endl; } return 0; }
#include <iostream> #include <map> #include <queue> #include <string> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define INF 114514810 #define ELEM(array) (sizeof(array) / sizeof *(array)) #define MAX_N 100 typedef unsigned int UINT; typedef long long ll; char num; string str; int main() { map<string, int> used; queue<string> zero; zero.push("01234567"); while (!zero.empty()) { string tmp; tmp = zero.front(); zero.pop(); int posi_zero = tmp.find("0"); if (0 == tmp.find("0")) { int dx[] = {1, 4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[0], tmp1[dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 1 || posi_zero == 2) { int dx[] = {-1, 1, 4}; REP(i, 3) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 3) { int dx[] = {-1, 4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 4) { int dx[] = {1, -4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 5 || posi_zero == 6) { int dx[] = {-1, 1, -4}; REP(i, 3) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } else if (tmp.find("0") == 7) { int dx[] = {-1, -4}; REP(i, 2) { string tmp1 = tmp; swap(tmp1[posi_zero], tmp1[posi_zero + dx[i]]); if (used.find(tmp1) == used.end()) { used[tmp1] = used[tmp] + 1; zero.push(tmp1); } } } } while (cin >> num) { str.push_back(num); REP(i, 7) { cin >> num; str.push_back(num); } cout << used[str] << endl; str.clear(); } return 0; }
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
753
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef pair<string, int> P; map<string, int> m; int main() { cin.tie(0); ios::sync_with_stdio(false); queue<P> q; q.push(P("01234567", 0)); m["01234567"] = 0; while (!q.empty()) { P p = q.front(); q.pop(); if (m[p.first] != p.second) continue; string s = p.first; int d[] = {1, -1, 4, -4}; for (int i = 0; i < 8; i++) { if (s[i] != '0') continue; for (int j = 0; j < 4; j++) { if (d[j] == 1 && (i == 3 || i == 7)) continue; if (d[j] == -1 && (i == 0 || i == 4)) continue; if (d[j] == 4 && 4 <= i) continue; if (d[j] == -4 && i <= 3) continue; swap(s[i], s[i + d[j]]); if (m.find(s) == m.end() || p.second + 1 < m[s]) { m[s] = p.second + 1; q.push(P(s, p.second + 1)); } swap(s[i], s[i + d[j]]); } } } string s; while (getline(cin, s)) { string ss; for (int i = 0; i < 8; i++) { ss += s[2 * i]; } cout << m[s] << endl; } }
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef pair<string, int> P; map<string, int> m; int main() { cin.tie(0); ios::sync_with_stdio(false); queue<P> q; q.push(P("01234567", 0)); m["01234567"] = 0; while (!q.empty()) { P p = q.front(); q.pop(); if (m[p.first] != p.second) continue; string s = p.first; int d[] = {1, -1, 4, -4}; for (int i = 0; i < 8; i++) { if (s[i] != '0') continue; for (int j = 0; j < 4; j++) { if (d[j] == 1 && (i == 3 || i == 7)) continue; if (d[j] == -1 && (i == 0 || i == 4)) continue; if (d[j] == 4 && 4 <= i) continue; if (d[j] == -4 && i <= 3) continue; swap(s[i], s[i + d[j]]); if (m.find(s) == m.end() || p.second + 1 < m[s]) { m[s] = p.second + 1; q.push(P(s, p.second + 1)); } swap(s[i], s[i + d[j]]); } } } string s; while (getline(cin, s)) { string ss; for (int i = 0; i < 8; i++) { ss += s[2 * i]; } cout << m[ss] << endl; } }
[["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
410
#include <bits/stdc++.h> using namespace std; typedef pair<int, string> P; int main() { int d[4] = {-1, 1, -4, 1}; map<string, int> ans; ans["01234567"] = 0; queue<P> que; que.push(P(0, "01234567")); while (que.size()) { P p = que.front(); que.pop(); int k = ans[p.second]; for (int i = 0; i < 4; i++) { int n = p.first + d[i]; if (i == 0 && n == 3) continue; if (i == 1 && n == 4) continue; if (n >= 0 && n < 8) { string tmp; tmp = p.second; tmp[p.first] = tmp[n]; tmp[n] = '0'; if (ans.find(tmp) == ans.end()) { ans[tmp] = k + 1; que.push(P(n, tmp)); } } } } string s; char t; while (cin >> t) { s += t; for (int i = 0; i < 7; i++) { cin >> t; s += t; } cout << ans[s] << endl; s.clear(); } return 0; }
#include <bits/stdc++.h> using namespace std; using namespace std; typedef pair<int, string> P; int main() { int d[4] = {-1, 1, -4, 4}; map<string, int> ans; ans["01234567"] = 0; queue<P> que; que.push(P(0, "01234567")); while (que.size()) { P p = que.front(); que.pop(); int k = ans[p.second]; for (int i = 0; i < 4; i++) { int n = p.first + d[i]; if (i == 0 && n == 3) continue; if (i == 1 && n == 4) continue; if (n >= 0 && n < 8) { string tmp; tmp = p.second; tmp[p.first] = tmp[n]; tmp[n] = '0'; if (ans.find(tmp) == ans.end()) { ans[tmp] = k + 1; que.push(P(n, tmp)); } } } } string s; char t; while (cin >> t) { s += t; for (int i = 0; i < 7; i++) { cin >> t; s += t; } cout << ans[s] << endl; s.clear(); } return 0; }
[["+", 36, 36, 36, 36, 0, 30, 0, 340, 0, 233], ["+", 36, 36, 36, 36, 0, 30, 0, 340, 0, 256], ["+", 36, 36, 36, 36, 0, 30, 0, 340, 0, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 340, 0, 35], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
301
#define LOCAL #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #define SIZE 50000 using namespace std; int map[8]; int factor[8]; int result[SIZE]; int dir[] = {-1, 1, -4, 4}; int cantor() { int ans = 0; for (int i = 0; i < 8; i++) { int num = 0; for (int j = i + 1; j < 8; j++) { if (map[i] > map[j]) num++; } ans += factor[7 - i] * num; } return ans; } void inv_cantor(int num) { bool visited[8] = {false}; for (int i = 0; i < 8; i++) { int divv = num / factor[7 - i]; num %= factor[7 - i]; int j; for (j = 0; j < 8; j++) { if (visited[j] == false) { if (divv == 0) break; divv--; } } map[i] = j; visited[j] = true; } } void init() { factor[0] = 1; for (int i = 1; i < 8; i++) factor[i] = factor[i - 1] * i; memset(result, 0, sizeof(result)); /*for(int i = 0; i < 8; i++) printf("%d ", factor[i]); printf("\n");*/ } inline void updata(queue<int> &q, int temp, int p0, int p1) { swap(map[p0], map[p1]); int s = cantor(); if (!result[s]) { result[s] = result[temp] + 1; q.push(s); } swap(map[p0], map[p1]); } void bfs() { result[0] = 1; queue<int> q; q.push(0); while (!q.empty()) { int temp = q.front(); q.pop(); inv_cantor(temp); /*for(int i = 0; i < 8; i++) printf("%d ", map[i]); printf("\n");*/ int zero_pos; for (int i = 0; i < 8; i++) { if (map[i] == 0) { zero_pos = i; break; } } int r = zero_pos % 4; if (r) { updata(q, temp, zero_pos - 1, zero_pos); } if (r < 3) { updata(q, temp, zero_pos + 1, zero_pos); } updata(q, temp, zero_pos, zero_pos + (zero_pos > 3 ? -4 : 4)); /*for(int i = 0; i < 4; i++){ int new_pos = zero_pos + dir[i]; if(0 <= new_pos && new_pos < 8 && !(zero_pos == 2 && new_pos == 3) && !(zero_pos == 3 && new_pos == 2)){ swap(map[zero_pos], map[new_pos]); int r = cantor(); if(result[r] == 0){ result[r] = result[temp] + 1; q.push(r); } swap(map[zero_pos], map[new_pos]); } }*/ } } int main(void) { #ifdef LOCAL freopen("data.in", "r", stdin); #endif init(); bfs(); while (scanf("%d", &map[0]) != EOF) { for (int i = 1; i < 8; i++) scanf("%d", &map[i]); int x = cantor(); printf("%d\n", result[x] - 1); } return 0; }
//#define LOCAL #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #define SIZE 50000 using namespace std; int map[8]; int factor[8]; int result[SIZE]; int dir[] = {-1, 1, -4, 4}; int cantor() { int ans = 0; for (int i = 0; i < 8; i++) { int num = 0; for (int j = i + 1; j < 8; j++) { if (map[i] > map[j]) num++; } ans += factor[7 - i] * num; } return ans; } void inv_cantor(int num) { bool visited[8] = {false}; for (int i = 0; i < 8; i++) { int divv = num / factor[7 - i]; num %= factor[7 - i]; int j; for (j = 0; j < 8; j++) { if (visited[j] == false) { if (divv == 0) break; divv--; } } map[i] = j; visited[j] = true; } } void init() { factor[0] = 1; for (int i = 1; i < 8; i++) factor[i] = factor[i - 1] * i; memset(result, 0, sizeof(result)); /*for(int i = 0; i < 8; i++) printf("%d ", factor[i]); printf("\n");*/ } inline void updata(queue<int> &q, int cur, int p0, int p1) { swap(map[p0], map[p1]); int s = cantor(); if (!result[s]) { result[s] = result[cur] + 1; q.push(s); } swap(map[p0], map[p1]); } void bfs() { result[0] = 1; queue<int> q; q.push(0); while (!q.empty()) { int temp = q.front(); q.pop(); inv_cantor(temp); /*for(int i = 0; i < 8; i++) printf("%d ", map[i]); printf("\n");*/ int zero_pos; for (int i = 0; i < 8; i++) { if (map[i] == 0) { zero_pos = i; break; } } int r = zero_pos % 4; if (r) { updata(q, temp, zero_pos - 1, zero_pos); } if (r < 3) { updata(q, temp, zero_pos + 1, zero_pos); } updata(q, temp, zero_pos, zero_pos + (zero_pos > 3 ? -4 : 4)); /*for(int i = 0; i < 4; i++){ int new_pos = zero_pos + dir[i]; if(0 <= new_pos && new_pos < 8 && !(zero_pos == 2 && new_pos == 3) && !(zero_pos == 3 && new_pos == 2)){ swap(map[zero_pos], map[new_pos]); int r = cantor(); if(result[r] == 0){ result[r] = result[temp] + 1; q.push(r); } swap(map[zero_pos], map[new_pos]); } }*/ } } int main(void) { #ifdef LOCAL freopen("data.in", "r", stdin); #endif init(); bfs(); while (scanf("%d", &map[0]) != EOF) { for (int i = 1; i < 8; i++) scanf("%d", &map[i]); int x = cantor(); printf("%d\n", result[x] - 1); } return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22]]
1
641
require 'pry' def to_xy(str, target) str.chars.each_with_index do |s, i| if target == s.to_i x = i%4 y = i < 4 ? 0 : 1 return x, y, i end end end def move_zero(str, mx, my) zx, zy, zi = to_xy(str, 0) (1..7).each do |i| sx, sy, si = to_xy(str, i) if (zx + mx) == sx and (zy + my) == sy ns = str.dup ns[zi], ns[si] = ns[si], ns[zi] return ns end end end rule = Struct.new('Rule', :can_move?, :move) rules = [ rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x <= 2 }, lambda { |str| move_zero(str, 1, 0) }), rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 0 }, lambda { |str| move_zero(str, 0, 1) }), rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x >= 1 }, lambda { |str| move_zero(str, -1, 0) }), rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 1 }, lambda { |str| move_zero(str, 0, -1) }) ] goal = '01234567' map_list = [goal] answers = {goal => 0} loop do search_map = map_list.shift break unless search_map rules.each do |rule| next unless rule.can_move?.call(search_map) next_map = rule.move.call(search_map) next if answers[next_map] answers[next_map.to_s] = answers[search_map] + 1 map_list.push(next_map) end end while s = gets puts answers[s.chomp.split.join] end
def to_xy(str, target) str.chars.each_with_index do |s, i| if target == s.to_i x = i%4 y = i < 4 ? 0 : 1 return x, y, i end end end def move_zero(str, mx, my) zx, zy, zi = to_xy(str, 0) (1..7).each do |i| sx, sy, si = to_xy(str, i) if (zx + mx) == sx and (zy + my) == sy ns = str.dup ns[zi], ns[si] = ns[si], ns[zi] return ns end end end rule = Struct.new('Rule', :can_move?, :move) rules = [ rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x <= 2 }, lambda { |str| move_zero(str, 1, 0) }), rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 0 }, lambda { |str| move_zero(str, 0, 1) }), rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x >= 1 }, lambda { |str| move_zero(str, -1, 0) }), rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 1 }, lambda { |str| move_zero(str, 0, -1) }) ] goal = '01234567' map_list = [goal] answers = {goal => 0} loop do search_map = map_list.shift break unless search_map rules.each do |rule| next unless rule.can_move?.call(search_map) next_map = rule.move.call(search_map) next if answers[next_map] answers[next_map.to_s] = answers[search_map] + 1 map_list.push(next_map) end end while s = gets puts answers[s.chomp.split.join] end
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 557, 0, 62], ["-", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6]]
4
428
puts $<.map{|l|(?0*(6-l.size)+l.chop).chars.map{|c|i=c.to_i l="*=****" l[i%5+3,0]=l[1-i/5,0]=" " l.chars}.transpose.map{|a|a*""}<<?\n}*?\n
puts $<.map{|l|(?0*(6-l.size)+l.chop).chars.map{|c|i=c.to_i l="*=****" l[i%5+3,0]=l[1-i/5,0]=" " l.chars}.transpose.map{|a|a<<?\n}*""}*?\n
[["+", 31, 652, 196, 196, 8, 734, 0, 738, 17, 151], ["+", 31, 652, 196, 196, 8, 734, 0, 738, 12, 125], ["+", 8, 734, 0, 738, 31, 652, 196, 196, 0, 46], ["-", 8, 734, 0, 738, 31, 652, 196, 196, 0, 46], ["-", 31, 652, 196, 196, 8, 734, 0, 738, 17, 151], ["-", 31, 652, 196, 196, 8, 734, 0, 738, 12, 125]]
4
88
# AOJ 0128 Abacus # Python3 2018.6.19 bal4u abacus = [ [ '*', '*', '*', '*', '*', ' ', ' ', ' ', ' ', ' ' ], [ ' ', ' ', ' ', ' ', ' ', '*', '*', '*', '*', '*' ], [ '=', '=', '=', '=', '=', '=', '=', '=', '=', '=' ], [ ' ', '*', '*', '*', '*', ' ', '*', '*', '*', '*' ], [ '*', ' ', '*', '*', '*', '*', ' ', '*', '*', '*' ], [ '*', '*', ' ', '*', '*', '*', '*', ' ', '*', '*' ], [ '*', '*', '*', ' ', '*', '*', '*', '*', ' ', '*' ], [ '*', '*', '*', '*', ' ', '*', '*', '*', '*', ' ' ]] ans = [[0 for c in range(5)] for r in range(8)] first = True while True: try: n = list(input()) except: break for i in range(5-len(n)): for r in range(8): ans[r][i] = abacus[r][0] for i in range(len(n)): for r in range(8): ans[r][5-len(n)+i] = abacus[r][int(n[i])] if first: first = False else: print() for r in range(8): print(*ans[r])
# AOJ 0128 Abacus # Python3 2018.6.19 bal4u abacus = [ [ '*', '*', '*', '*', '*', ' ', ' ', ' ', ' ', ' ' ], [ ' ', ' ', ' ', ' ', ' ', '*', '*', '*', '*', '*' ], [ '=', '=', '=', '=', '=', '=', '=', '=', '=', '=' ], [ ' ', '*', '*', '*', '*', ' ', '*', '*', '*', '*' ], [ '*', ' ', '*', '*', '*', '*', ' ', '*', '*', '*' ], [ '*', '*', ' ', '*', '*', '*', '*', ' ', '*', '*' ], [ '*', '*', '*', ' ', '*', '*', '*', '*', ' ', '*' ], [ '*', '*', '*', '*', ' ', '*', '*', '*', '*', ' ' ]] ans = [['' for c in range(5)] for r in range(8)] first = True while True: try: n = list(input()) except: break for i in range(5-len(n)): for r in range(8): ans[r][i] = abacus[r][0] for i in range(len(n)): for r in range(8): ans[r][5-len(n)+i] = abacus[r][int(n[i])] if first: first = False else: print() for r in range(8): print(*ans[r], sep='')
[["-", 0, 1, 0, 662, 12, 658, 8, 658, 8, 612], ["+", 0, 662, 12, 658, 8, 658, 8, 557, 0, 654], ["+", 0, 662, 12, 658, 8, 658, 8, 557, 0, 655], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 654], ["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 655]]
5
491
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static BufferedReader br = null; static { br = new BufferedReader(new InputStreamReader(System.in)); } /** * @param args */ public static void main(String[] args) { int cc = 0; int lc = 0; Circle[] cs = null; Line[] ls = null; while ((cc = parseCnt()) != 0) { cs = new Circle[cc]; for (int i = 0; i < cs.length; i++) { cs[i] = parseCircle(); } lc = parseCnt(); ls = new Line[lc]; for (int i = 0; i < ls.length; i++) { ls[i] = parseLine(); solve(cs, ls[i]); } } } private static void solve(Circle[] cs, Line ln) { double dk = 0.0; double xp = 0.0; double yp = 0.0; double sp = 0.0; double ds = 0.0; boolean dg = true; Line lt = null; for (int i = 0; i < cs.length && dg; i++) { dk = (-1.0) * (ln.da * cs[i].dx + ln.db * cs[i].dy + ln.dc) / (ln.da * ln.dvx + ln.db * ln.dvy); sp = (cs[i].dr * cs[i].dr) - (dk * dk); if (sp >= 0) { xp = cs[i].dx + dk * ln.dvx; yp = cs[i].dy + dk * ln.dvy; ds = Math.sqrt(sp); lt = new Line(xp + ds * ln.dex, yp + ds * ln.dey, xp - ds * ln.dex, yp - ds * ln.dey); { boolean i1 = lt.isInner(ln.dxs, ln.dys); boolean i2 = lt.isInner(ln.dxe, ln.dye); if (i1 != i2) { dg = false; } else if (!i1 && !i2) { dg = (lt.getDirection(ln.dxs, ln.dys) == lt.getDirection(ln.dxe, ln.dye)); } else { dg = Math.abs(ds * ln.dex) >= 1e-6 && Math.abs(ds * ln.dey) >= 1e-6; } } } } System.out.println((dg) ? "Danger" : "Safe"); } private static Line parseLine() { Line lin = null; String str = null; if ((str = parseStdin()) != null) { String[] lines = str.split(" "); lin = new Line(Integer.parseInt(lines[0]), Integer.parseInt(lines[1]), Integer.parseInt(lines[2]), Integer.parseInt(lines[3])); } return lin; } private static Circle parseCircle() { Circle cir = null; String str = null; if ((str = parseStdin()) != null) { String[] lines = str.split(" "); cir = new Circle(Integer.parseInt(lines[0]), Integer.parseInt(lines[1]), Integer.parseInt(lines[2])); } return cir; } private static int parseCnt() { int cnt = 0; String str = null; if ((str = parseStdin()) != null) { cnt = Integer.parseInt(str); } return cnt; } private static String parseStdin() { String stdin = null; try { String tmp = br.readLine(); if (tmp != null) { if (!tmp.isEmpty()) stdin = tmp; } } catch (IOException e) { } return stdin; } } class Circle { public double dx = 0.0; public double dy = 0.0; public double dr = 0.0; public Circle(double x, double y, double r) { dx = x; dy = y; dr = r; } } class Line { public double dxs = 0.0; public double dys = 0.0; public double dxe = 0.0; public double dye = 0.0; public double dex = 0.0; public double dey = 0.0; public double dvx = 0.0; public double dvy = 0.0; public double da = 0.0; public double db = 0.0; public double dc = 0.0; public double dl = 0.0; public double dxmn = 0.0; public double dxmx = 0.0; public double dymn = 0.0; public double dymx = 0.0; public Line(double xs, double ys, double xe, double ye) { dxs = xs; dys = ys; dxe = xe; dye = ye; da = dye - dys; db = dxs - dxe; dc = (-1.0) * (da * xs + db * ys); dl = Math.sqrt(da * da + db * db); dex = (dxe - dxs) / dl; dey = (dye - dys) / dl; dvx = dey * (-1.0); dvy = dex; dxmn = Math.min(dxs, dxe); dxmx = Math.max(dxs, dxe); dymn = Math.min(dys, dye); dymx = Math.max(dys, dye); } public boolean isInner(double x, double y) { return (dxmn <= x && x <= dxmx && dymn <= y && y <= dymx); } public int getDirection(double x, double y) { final int D_N = 0; final int D_U = 1; final int D_D = 2; final int D_L = 4; final int D_R = 8; int dir = D_N; dir += (x < dxmn) ? D_L : D_N; dir += (x > dxmx) ? D_R : D_N; dir += (y < dymn) ? D_U : D_N; dir += (y > dymx) ? D_D : D_N; return dir; } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static BufferedReader br = null; static { br = new BufferedReader(new InputStreamReader(System.in)); } /** * @param args */ public static void main(String[] args) { int cc = 0; int lc = 0; Circle[] cs = null; Line[] ls = null; while ((cc = parseCnt()) != 0) { cs = new Circle[cc]; for (int i = 0; i < cs.length; i++) { cs[i] = parseCircle(); } lc = parseCnt(); ls = new Line[lc]; for (int i = 0; i < ls.length; i++) { ls[i] = parseLine(); solve(cs, ls[i]); } } } private static void solve(Circle[] cs, Line ln) { double dk = 0.0; double xp = 0.0; double yp = 0.0; double sp = 0.0; double ds = 0.0; boolean dg = true; Line lt = null; for (int i = 0; i < cs.length && dg; i++) { dk = (-1.0) * (ln.da * cs[i].dx + ln.db * cs[i].dy + ln.dc) / (ln.da * ln.dvx + ln.db * ln.dvy); sp = (cs[i].dr * cs[i].dr) - (dk * dk); if (sp >= 0) { xp = cs[i].dx + dk * ln.dvx; yp = cs[i].dy + dk * ln.dvy; ds = Math.sqrt(sp); lt = new Line(xp + ds * ln.dex, yp + ds * ln.dey, xp - ds * ln.dex, yp - ds * ln.dey); { boolean i1 = lt.isInner(ln.dxs, ln.dys); boolean i2 = lt.isInner(ln.dxe, ln.dye); if (i1 != i2) { dg = false; } else if (!i1 && !i2) { dg = (lt.getDirection(ln.dxs, ln.dys) == lt.getDirection(ln.dxe, ln.dye)); } else { dg = Math.abs(ds * ln.dex) >= 1e-6 || Math.abs(ds * ln.dey) >= 1e-6; } } } } System.out.println((dg) ? "Danger" : "Safe"); } private static Line parseLine() { Line lin = null; String str = null; if ((str = parseStdin()) != null) { String[] lines = str.split(" "); lin = new Line(Integer.parseInt(lines[0]), Integer.parseInt(lines[1]), Integer.parseInt(lines[2]), Integer.parseInt(lines[3])); } return lin; } private static Circle parseCircle() { Circle cir = null; String str = null; if ((str = parseStdin()) != null) { String[] lines = str.split(" "); cir = new Circle(Integer.parseInt(lines[0]), Integer.parseInt(lines[1]), Integer.parseInt(lines[2])); } return cir; } private static int parseCnt() { int cnt = 0; String str = null; if ((str = parseStdin()) != null) { cnt = Integer.parseInt(str); } return cnt; } private static String parseStdin() { String stdin = null; try { String tmp = br.readLine(); if (tmp != null) { if (!tmp.isEmpty()) stdin = tmp; } } catch (IOException e) { } return stdin; } } class Circle { public double dx = 0.0; public double dy = 0.0; public double dr = 0.0; public Circle(double x, double y, double r) { dx = x; dy = y; dr = r; } } class Line { public double dxs = 0.0; public double dys = 0.0; public double dxe = 0.0; public double dye = 0.0; public double dex = 0.0; public double dey = 0.0; public double dvx = 0.0; public double dvy = 0.0; public double da = 0.0; public double db = 0.0; public double dc = 0.0; public double dl = 0.0; public double dxmn = 0.0; public double dxmx = 0.0; public double dymn = 0.0; public double dymx = 0.0; public Line(double xs, double ys, double xe, double ye) { dxs = xs; dys = ys; dxe = xe; dye = ye; da = dye - dys; db = dxs - dxe; dc = (-1.0) * (da * xs + db * ys); dl = Math.sqrt(da * da + db * db); dex = (dxe - dxs) / dl; dey = (dye - dys) / dl; dvx = dey * (-1.0); dvy = dex; dxmn = Math.min(dxs, dxe); dxmx = Math.max(dxs, dxe); dymn = Math.min(dys, dye); dymx = Math.max(dys, dye); } public boolean isInner(double x, double y) { return (dxmn <= x && x <= dxmx && dymn <= y && y <= dymx); } public int getDirection(double x, double y) { final int D_N = 0; final int D_U = 1; final int D_D = 2; final int D_L = 4; final int D_R = 8; int dir = D_N; dir += (x < dxmn) ? D_L : D_N; dir += (x > dxmx) ? D_R : D_N; dir += (y < dymn) ? D_U : D_N; dir += (y > dymx) ? D_D : D_N; return dir; } }
[["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 98], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 106]]
3
1,267
#include <math.h> #include <stdio.h> typedef struct { int x; int y; int r; } WALL; // 内積 #define dotProduct(x1, y1, x2, y2) ((x1 * x2) + (y1 * y2)) // 円の中に点があるかどうか #define inCircle(x1, y1, c) \ (pow(c.x - x1, 2) + pow(c.y - y1, 2) < c.r * c.r ? 1 : 0) int judge(WALL w, int tx, int ty, int sx, int sy) { // V : 線分始点から終点へのベクトル // C : 線分始点から円中心へのベクトル int Vx = tx - sx; int Vy = ty - sy; int Cx = w.x - sx; int Cy = w.y - sy; int n1, n2, n3; int in_t = inCircle(tx, ty, w); int in_s = inCircle(sx, sy, w); if (in_t && in_s) return 0; if (in_t || in_s) return 1; //二つのベクトルの内積を求める n1 = dotProduct(Vx, Vy, Cx, Cy); n2 = dotProduct(Vx, Vy, Vx, Vy); n3 = dotProduct(Cx, Cy, Cx, Cy); if (n1 > n2) return 0; return (n3 - (n1 * n1 / n2) <= pow(w.r, 2)) ? 1 : 0; } int main(void) { int n; while (scanf("%d", &n), n) { int i, m; WALL w[100]; for (i = 0; i < n; i++) { scanf("%d%d%d", &w[i].x, &w[i].y, &w[i].r); } scanf("%d", &m); for (i = 0; i < m; i++) { int j, safe = 0; int tx, ty, sx, sy; scanf("%d%d%d%d", &tx, &ty, &sx, &sy); for (j = 0; j < n; j++) if (judge(w[j], tx, ty, sx, sy) == 1) { safe = 1; break; } if (safe) printf("Safe\n"); else printf("Danger\n"); } } return 0; }
#include <math.h> #include <stdio.h> typedef struct { int x; int y; int r; } WALL; // 内積 #define dotProduct(x1, y1, x2, y2) ((x1 * x2) + (y1 * y2)) // 円の中に点があるかどうか #define inCircle(x1, y1, c) \ (pow(c.x - x1, 2) + pow(c.y - y1, 2) < c.r * c.r ? 1 : 0) int judge(WALL w, int tx, int ty, int sx, int sy) { // V : 線分始点から終点へのベクトル // C : 線分始点から円中心へのベクトル int Vx = tx - sx; int Vy = ty - sy; int Cx = w.x - sx; int Cy = w.y - sy; int n1, n2, n3; int in_t = inCircle(tx, ty, w); int in_s = inCircle(sx, sy, w); if (in_t && in_s) return 0; if (in_t || in_s) return 1; //二つのベクトルの内積を求める n1 = dotProduct(Vx, Vy, Cx, Cy); n2 = dotProduct(Vx, Vy, Vx, Vy); n3 = dotProduct(Cx, Cy, Cx, Cy); if (n1 < 0 || n1 > n2) return 0; return (n3 - (n1 * n1 / n2) <= pow(w.r, 2)) ? 1 : 0; } int main(void) { int n; while (scanf("%d", &n), n) { int i, m; WALL w[100]; for (i = 0; i < n; i++) { scanf("%d%d%d", &w[i].x, &w[i].y, &w[i].r); } scanf("%d", &m); for (i = 0; i < m; i++) { int j, safe = 0; int tx, ty, sx, sy; scanf("%d%d%d%d", &tx, &ty, &sx, &sy); for (j = 0; j < n; j++) if (judge(w[j], tx, ty, sx, sy) == 1) { safe = 1; break; } if (safe) printf("Safe\n"); else printf("Danger\n"); } } return 0; }
[["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22]]
0
430
#include <algorithm> #include <cmath> #include <stdio.h> using namespace std; const double EPS = 1e-10; double add(double a, double b) { // if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0; return a + b; } typedef struct Vec { double x, y; Vec() {} Vec(double x, double y) : x(x), y(y) {} Vec operator+(Vec v) { return Vec(add(x, v.x), add(y, v.y)); } Vec operator-(Vec v) { return Vec(add(x, -v.x), add(y, -v.y)); } Vec operator*(double d) { return Vec(x * d, y * d); } } Vec; double dot(Vec a, Vec b) { return add(a.x * b.x, a.y * b.y); } double det(Vec a, Vec b) { return add(a.x * b.y, -a.y * b.x); } typedef struct Cer { double r; Vec cp; } Cer; double vabs(Vec a) { return hypot(a.x, a.y); } double ch(Vec a, Vec b, Cer c) { if (dot(b - a, c.cp - a) < EPS) return vabs(b - a); if (dot(a - b, c.cp - b) < EPS) return vabs(c.cp - b); return fabs(det(b - a, c.cp - a)) / vabs(b - a); } int chC(Vec a, Cer c) { return hypot(a.x - c.cp.x, a.y - c.cp.y) <= c.r ? 1 : 0; } int N, M, i, j, f; double m, d; Cer W[100]; int main() { for (; scanf("%d", &N), N;) { for (i = 0; i < N; i++) scanf("%lf%lf%lf", &W[i].cp.x, &W[i].cp.y, &W[i].r); scanf("%d", &M); for (i = 0; i < M; i++) { f = 0; Vec t, s; scanf("%lf%lf%lf%lf", &t.x, &t.y, &s.x, &s.y); for (j = 0; j < N; j++) { if (chC(s, W[j]) && chC(t, W[j])) continue; if (ch(t, s, W[j]) <= W[j].r) f = 1; } puts(f ? "Safe" : "Danger"); } } return 0; }
#include <algorithm> #include <cmath> #include <stdio.h> using namespace std; const double EPS = 1e-10; double add(double a, double b) { // if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0; return a + b; } typedef struct Vec { double x, y; Vec() {} Vec(double x, double y) : x(x), y(y) {} Vec operator+(Vec v) { return Vec(add(x, v.x), add(y, v.y)); } Vec operator-(Vec v) { return Vec(add(x, -v.x), add(y, -v.y)); } Vec operator*(double d) { return Vec(x * d, y * d); } } Vec; double dot(Vec a, Vec b) { return add(a.x * b.x, a.y * b.y); } double det(Vec a, Vec b) { return add(a.x * b.y, -a.y * b.x); } typedef struct Cer { double r; Vec cp; } Cer; double vabs(Vec a) { return hypot(a.x, a.y); } double ch(Vec a, Vec b, Cer c) { if (dot(b - a, c.cp - a) < EPS) return vabs(c.cp - a); if (dot(a - b, c.cp - b) < EPS) return vabs(c.cp - b); return fabs(det(b - a, c.cp - a)) / vabs(b - a); } int chC(Vec a, Cer c) { return hypot(a.x - c.cp.x, a.y - c.cp.y) <= c.r ? 1 : 0; } int N, M, i, j, f; double m, d; Cer W[100]; int main() { for (; scanf("%d", &N), N;) { for (i = 0; i < N; i++) scanf("%lf%lf%lf", &W[i].cp.x, &W[i].cp.y, &W[i].r); scanf("%d", &M); for (i = 0; i < M; i++) { f = 0; Vec t, s; scanf("%lf%lf%lf%lf", &t.x, &t.y, &s.x, &s.y); for (j = 0; j < N; j++) { if (chC(s, W[j]) && chC(t, W[j])) continue; if (ch(t, s, W[j]) <= W[j].r) f = 1; } puts(f ? "Safe" : "Danger"); } } return 0; }
[["-", 64, 37, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 16, 31, 118, 119, 120]]
1
619
// 36 #include <cmath> #include <complex> #include <iostream> using namespace std; typedef complex<double> P; double cr(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); } int main() { for (int n; cin >> n, n;) { P w[100]; double r[100]; for (int i = 0; i < n; i++) { double x, y; cin >> x >> y >> r[i]; w[i] = P(x, y); } int m; cin >> m; while (m--) { P t, s, l; double tx, ty, sx, sy; cin >> tx >> ty >> sx >> sy; t = P(tx, ty); s = P(sx, sy); l = t - s; int i; for (i = 0; i < n; i++) { if ((abs(w[i] - t) - r[i]) * (abs(w[i] - s) - r[i]) < 0) break; if (abs(w[i] - t) > r[i] && cr((t - s) * P(0, 1), w[i] - s) * cr((s - t) * P(0, 1), w[i] - t) > 0 && abs(w[i] - s) * sin(fabs(arg(w[i] - s) - arg(l))) <= r[i] + 1e-9) break; } cout << ((i < n) ? "Safe" : "Danger") << endl; } } return 0; }
// 36 #include <cmath> #include <complex> #include <iostream> using namespace std; typedef complex<double> P; double cr(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); } int main() { for (int n; cin >> n, n;) { P w[100]; double r[100]; for (int i = 0; i < n; i++) { double x, y; cin >> x >> y >> r[i]; w[i] = P(x, y); } int m; cin >> m; while (m--) { P t, s, l; double tx, ty, sx, sy; cin >> tx >> ty >> sx >> sy; t = P(tx, ty); s = P(sx, sy); l = t - s; int i; for (i = 0; i < n; i++) { if ((abs(w[i] - t) - r[i]) * (abs(w[i] - s) - r[i]) < 0) break; if (abs(w[i] - t) > r[i] && cr((t - s) * P(0, 1), w[i] - s) * cr((s - t) * P(0, 1), w[i] - t) > 0 && abs(w[i] - s) * fabs(sin(arg(w[i] - s) - arg(l))) <= r[i] + 1e-9) break; } cout << ((i < n) ? "Safe" : "Danger") << endl; } } return 0; }
[["-", 51, 16, 12, 16, 31, 16, 12, 2, 63, 22], ["-", 12, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 12, 2, 3, 4, 0, 2, 63, 22]]
1
380
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main() { int i, j, n, m, f; int a, b, c, d, r, x1, x2, y1, y2, mx[101], my[101], mr[101]; vector<int> tx, ty, sx, sy; while (cin >> n) { if (n == 0) break; for (i = 0; i < n; i++) cin >> mx[i] >> my[i] >> mr[i]; cin >> m; for (i = 0; i < m; i++) { cin >> a >> b >> c >> r; tx.push_back(a); ty.push_back(b); sx.push_back(c); sy.push_back(r); } for (i = 0; i < m; i++) { for (j = 0, f = 0; j < n; j++) { x1 = tx[i] - mx[j]; y1 = ty[i] - my[j]; x2 = sx[i] - mx[j]; y2 = sy[i] - my[j]; r = mr[j]; a = x1 * x1 + y1 * y1; b = x2 * x2 + y2 * y2; if (a < r * r && b < r * r) continue; if ((a < r * r && b > r * r) || (a > r * r && b < r * r)) f = 1; a = x2 - x1; b = y2 - y1; c = b * b * (r * r - x1 * x1) + a * a * (r * r - y1 * y1) + a * b * y1 * x1; d = (a * (-x1) + b * (-y1)) * ((-a) * (-x2) + (-b) * (-y2)); if (c >= 0 && d >= 0) f = 1; } if (f == 1) cout << "Safe" << endl; else cout << "Danger" << endl; } tx.clear(); ty.clear(); sx.clear(); sy.clear(); } return 0; }
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main() { int i, j, n, m, f; int a, b, c, d, r, x1, x2, y1, y2, mx[101], my[101], mr[101]; vector<int> tx, ty, sx, sy; while (cin >> n) { if (n == 0) break; for (i = 0; i < n; i++) cin >> mx[i] >> my[i] >> mr[i]; cin >> m; for (i = 0; i < m; i++) { cin >> a >> b >> c >> r; tx.push_back(a); ty.push_back(b); sx.push_back(c); sy.push_back(r); } for (i = 0; i < m; i++) { for (j = 0, f = 0; j < n; j++) { x1 = tx[i] - mx[j]; y1 = ty[i] - my[j]; x2 = sx[i] - mx[j]; y2 = sy[i] - my[j]; r = mr[j]; a = x1 * x1 + y1 * y1; b = x2 * x2 + y2 * y2; if (a < r * r && b < r * r) continue; if ((a < r * r && b > r * r) || (a > r * r && b < r * r)) f = 1; a = x2 - x1; b = y2 - y1; c = b * b * (r * r - x1 * x1) + a * a * (r * r - y1 * y1) + 2 * a * b * y1 * x1; d = (a * (-x1) + b * (-y1)) * ((-a) * (-x2) + (-b) * (-y2)); if (c >= 0 && d >= 0) f = 1; } if (f == 1) cout << "Safe" << endl; else cout << "Danger" << endl; } tx.clear(); ty.clear(); sx.clear(); sy.clear(); } return 0; }
[["+", 12, 16, 31, 16, 31, 16, 31, 16, 31, 13], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 17, 48]]
1
489
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef pair<double, P> C; vector<C> circles; #define FST first #define SND second typedef pair<P, P> S; #define EPS (1e-5) double dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); } double cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); } double distanceLP(S s, P a) { // d = |y||sin(th)| = |x||y|sin(th)/|x| = |cross(x, y)|/|x| return abs(cross(s.SND - s.FST, a - s.FST)) / abs(s.SND - s.FST); } double distanceSP(S s, P a) { // 2ベクトルのなす角が鈍角なら端点と1点との距離を返す if (dot(s.SND - s.FST, a - s.FST) < EPS) return abs(a - s.FST); if (dot(s.FST - s.SND, a - s.SND) < EPS) return abs(a - s.SND); return distanceLP(s, a); } int main() { int N; while (cin >> N && N) { circles.clear(); circles.resize(N); for (int i = 0; i < N; i++) { int x, y, r; cin >> x >> y >> r; circles[i] = C(r, P(x, y)); } int Q; cin >> Q; while (Q--) { int x, y; cin >> x >> y; P taro(x, y); cin >> x >> y; P ogre(x, y); for (int i = 0; i < N; i++) { if (distanceSP(S(taro, ogre), circles[i].SND) < circles[i].FST) { if (abs(circles[i].SND - taro) > circles[i].FST || abs(circles[i].SND - ogre) > circles[i].FST) { cout << "Safe" << endl; goto EXIT; } } } cout << "Danger" << endl; EXIT:; } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef pair<double, P> C; vector<C> circles; #define FST first #define SND second typedef pair<P, P> S; #define EPS (1e-5) double dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); } double cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); } double distanceLP(S s, P a) { // d = |y||sin(th)| = |x||y|sin(th)/|x| = |cross(x, y)|/|x| return abs(cross(s.SND - s.FST, a - s.FST)) / abs(s.SND - s.FST); } double distanceSP(S s, P a) { // 2ベクトルのなす角が鈍角なら端点と1点との距離を返す if (dot(s.SND - s.FST, a - s.FST) < EPS) return abs(a - s.FST); if (dot(s.FST - s.SND, a - s.SND) < EPS) return abs(a - s.SND); return distanceLP(s, a); } int main() { int N; while (cin >> N && N) { circles.clear(); circles.resize(N); for (int i = 0; i < N; i++) { int x, y, r; cin >> x >> y >> r; circles[i] = C(r, P(x, y)); } int Q; cin >> Q; while (Q--) { int x, y; cin >> x >> y; P taro(x, y); cin >> x >> y; P ogre(x, y); for (int i = 0; i < N; i++) { if (distanceSP(S(taro, ogre), circles[i].SND) < circles[i].FST + EPS) { if (abs(circles[i].SND - taro) > circles[i].FST + EPS || abs(circles[i].SND - ogre) > circles[i].FST + EPS) { cout << "Safe" << endl; goto EXIT; } } } cout << "Danger" << endl; EXIT:; } } return 0; }
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 17, 72], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 12, 22]]
1
482
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define pu push #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 #define sz(x) ((int)(x).size()) #define fi first #define sec second #define SORT(x) sort((x).begin(), (x).end()) #define all(x) (x).begin(), (x).end() #define EQ(a, b) (abs((a) - (b)) < EPS) int n, m; vector<P> vec; vector<int> rad; P s, t; ll sq(ll x) { return x * x; } bool in(int x, P a) { return sq(a.fi - vec[x].fi) + sq(a.sec - vec[x].sec) < rad[x] * rad[x]; } bool check() { for (int i = 0; i < n; i++) { bool in1, in2; in1 = in(i, s); in2 = in(i, t); if (in1 != in2) return false; if (in1 && in2) continue; ll a = s.fi, b = s.sec, c = t.fi, d = t.sec, p = vec[i].fi, q = vec[i].sec; if (a > c) { swap(a, c); swap(c, d); } if (a == c) { if (min(b, d) <= vec[i].sec && vec[i].sec <= max(b, d) && abs(vec[i].fi - a) <= rad[i]) { return false; } else continue; } ll A = sq(d - b) + sq(c - a); ll B = (b * c - a * d) * (d - b) - p * sq(c - a) - (c - a) * (d - b) * q; ll C = p * p * sq(c - a) + sq(b * c - a * d - q * c + q * a) - sq(rad[i]) * sq(c - a); // cout << "At circle No." << i+1 << ' '<< A << ' ' << B << ' ' << C << ' // ' << B*B-A*C<< endl; if (B * B - A * C < 0) continue; else if (B * B - A * C == 0) { if (a <= (-B / A) && (-B / A) <= c) return false; else continue; } else { double ans1 = (-B + sqrt(B * B - A * C)) / A; double ans2 = (-B - sqrt(B * B - A * C)) / A; if (ans1 >= a && ans2 <= c) return false; else continue; } } return true; } int main() { while (1) { vec.clear(); rad.clear(); scanf("%d", &n); if (n == 0) break; for (int i = 0; i < n; i++) { P k; int r; scanf("%d %d %d", &k.fi, &k.sec, &r); vec.pb(k); rad.pb(r); } scanf("%d", &m); for (int i = 0; i < m; i++) { scanf("%d %d %d %d", &t.fi, &t.sec, &s.fi, &s.sec); if (check()) puts("Danger"); else puts("Safe"); } } return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define pu push #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 #define sz(x) ((int)(x).size()) #define fi first #define sec second #define SORT(x) sort((x).begin(), (x).end()) #define all(x) (x).begin(), (x).end() #define EQ(a, b) (abs((a) - (b)) < EPS) int n, m; vector<P> vec; vector<int> rad; P s, t; ll sq(ll x) { return x * x; } bool in(int x, P a) { return sq(a.fi - vec[x].fi) + sq(a.sec - vec[x].sec) < rad[x] * rad[x]; } bool check() { for (int i = 0; i < n; i++) { bool in1, in2; in1 = in(i, s); in2 = in(i, t); if (in1 != in2) return false; if (in1 && in2) continue; ll a = s.fi, b = s.sec, c = t.fi, d = t.sec, p = vec[i].fi, q = vec[i].sec; if (a > c) { swap(a, c); swap(b, d); } if (a == c) { if (min(b, d) <= vec[i].sec && vec[i].sec <= max(b, d) && abs(vec[i].fi - a) <= rad[i]) { return false; } else continue; } ll A = sq(d - b) + sq(c - a); ll B = (b * c - a * d) * (d - b) - p * sq(c - a) - (c - a) * (d - b) * q; ll C = p * p * sq(c - a) + sq(b * c - a * d - q * c + q * a) - sq(rad[i]) * sq(c - a); // cout << "At circle No." << i+1 << ' '<< A << ' ' << B << ' ' << C << ' // ' << B*B-A*C<< endl; if (B * B - A * C < 0) continue; else if (B * B - A * C == 0) { if (a <= (-B / A) && (-B / A) <= c) return false; else continue; } else { double ans1 = (-B + sqrt(B * B - A * C)) / A; double ans2 = (-B - sqrt(B * B - A * C)) / A; if (ans1 >= a && ans2 <= c) return false; else continue; } } return true; } int main() { while (1) { vec.clear(); rad.clear(); scanf("%d", &n); if (n == 0) break; for (int i = 0; i < n; i++) { P k; int r; scanf("%d %d %d", &k.fi, &k.sec, &r); vec.pb(k); rad.pb(r); } scanf("%d", &m); for (int i = 0; i < m; i++) { scanf("%d %d %d %d", &t.fi, &t.sec, &s.fi, &s.sec); if (check()) puts("Danger"); else puts("Safe"); } } return 0; }
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
787
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; int i, j = 0, k = 30; char az[26]; char str[1025]; char queue[60]; scanf("%d", &n); for (i = 0; i < n; i++) { k = 30; memset(az, 0, 26); memset(str, 0, 1025); memset(queue, 0, 60); scanf("%s", str); for (j = 0; j < 1025; j += 3) { if (az[str[j] - 'a'] == 0 && str[j] != 0) { az[str[j] - 'a'] = 1; queue[k] = str[j]; } else if (str[j] == '\0') { break; } switch (str[j + 2]) { case '>': k++; break; case '-': k--; break; default: break; } } for (i = 0; i < 60; i++) { if (queue[i]) { printf("%c", queue[i]); } } puts(""); } return 0; }
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; int i, j = 0, k = 30; char az[26]; char str[1025]; char queue[60]; scanf("%d", &n); for (i = 0; i < n; i++) { k = 30; memset(az, 0, 26); memset(str, 0, 1025); memset(queue, 0, 60); scanf("%s", str); for (j = 0; j < 1025; j += 3) { if (az[str[j] - 'a'] == 0 && str[j] != 0) { az[str[j] - 'a'] = 1; queue[k] = str[j]; } else if (str[j] == '\0') { break; } switch (str[j + 2]) { case '>': k++; break; case '-': k--; break; default: break; } } for (j = 0; j < 60; j++) { if (queue[j]) { printf("%c", queue[j]); } } puts(""); } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 69, 71, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 69, 71, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22]]
0
270
#include <stdio.h> #include <string.h> int main(void) { int i, j, k; char map[8][9]; char cmap[8][9]; for (i = 0; i < 8; ++i) { scanf("%s", map[i]); } for (i = 1; i < 4; ++i) { memcpy(cmap, map, sizeof(map)); for (j = 0; j < 8; ++j) { for (k = 0; k < 8; ++k) { map[j][k] = cmap[7 - k][j]; } } printf("%d\n", i * 90); for (i = 0; i < 8; ++i) { printf("%s\n", map[i]); } } return 0; }
#include <stdio.h> #include <string.h> int main(void) { int i, j, k; char map[8][9]; char cmap[8][9]; for (i = 0; i < 8; ++i) { scanf("%s", map[i]); } for (i = 1; i < 4; ++i) { memcpy(cmap, map, sizeof(map)); for (j = 0; j < 8; ++j) { for (k = 0; k < 8; ++k) { map[j][k] = cmap[7 - k][j]; } } printf("%d\n", i * 90); for (j = 0; j < 8; ++j) { printf("%s\n", map[j]); } } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22]]
0
181
#include <stdio.h> int main(int argc, const char *argv[]) { int x, y; char data[8][8]; for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { scanf("%c", &data[x][y]); } getchar(); } printf("90\n"); for (x = 0; x < 8; x++) { for (y = 7; y >= 0; y--) { printf("%c", data[y][x]); } printf("\n"); } printf("180\n"); for (x = 7; x >= 0; x--) { for (y = 7; y >= 0; y--) { printf("%c", data[x][y]); } printf("\n"); } printf("270\n"); for (x = 7; x >= 0; x--) { for (y = 0; y < 8; y++) { printf("%c", data[x][y]); } printf("\n"); } return 0; }
#include <stdio.h> int main(int argc, const char *argv[]) { int x, y; char data[8][8]; for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { scanf("%c", &data[x][y]); } getchar(); } printf("90\n"); for (x = 0; x < 8; x++) { for (y = 7; y >= 0; y--) { printf("%c", data[y][x]); } printf("\n"); } printf("180\n"); for (x = 7; x >= 0; x--) { for (y = 7; y >= 0; y--) { printf("%c", data[x][y]); } printf("\n"); } printf("270\n"); for (x = 7; x >= 0; x--) { for (y = 0; y < 8; y++) { printf("%c", data[y][x]); } printf("\n"); } return 0; }
[["-", 0, 2, 3, 4, 0, 69, 28, 69, 71, 22], ["+", 0, 2, 3, 4, 0, 69, 28, 69, 71, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22]]
0
264
#include <stdio.h> #include <string.h> int rotate(char pat[8][9]) { char bitmap[8][9]; int x, y; for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { bitmap[x][7 - y] = pat[y][x]; } } memcpy(pat, bitmap, sizeof(bitmap)); return 0; } int main(void) { char pat[8][9]; int i; for (i = 0; i < 8; i++) { scanf("%s", pat[i]); } printf("90\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); printf("180\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); printf("270\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); return 0; }
#include <stdio.h> #include <string.h> int rotate(char pat[8][9]) { char bitmap[8][9] = {0}; int x, y; for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { bitmap[x][7 - y] = pat[y][x]; } } memcpy(pat, bitmap, sizeof(bitmap)); return 0; } int main(void) { char pat[8][9]; int i; for (i = 0; i < 8; i++) { scanf("%s", pat[i]); } printf("90\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); printf("180\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); printf("270\n"); rotate(pat); for (i = 0; i < 8; i++) printf("%s\n", pat[i]); return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
0
261
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); char c[8][8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c[i][j]; } } cout << 90 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - j][i]; } cout << endl; } cout << 180 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - i][7 - j]; } cout << endl; } cout << 270 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[i][7 - j]; } cout << endl; } return 0; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); char c[8][8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c[i][j]; } } cout << 90 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - j][i]; } cout << endl; } cout << 180 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - i][7 - j]; } cout << endl; } cout << 270 << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[j][7 - i]; } cout << endl; } return 0; }
[["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
249
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define reep(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) reep((i), 0, (n)) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define EPS 1e-8 #define F first #define S second #define mkp make_pair static const double PI = 6 * asin(0.5); typedef long long ll; typedef complex<double> CP; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; static const int INF = 1 << 24; template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } // v.erase(unique(v.begin(),v.end()),v.end()); int main() { vector<string> v(8); rep(i, 8) { cin >> v[i]; } cout << 90 << endl; rep(i, 8) { rep(j, 8) { cout << v[7 - i][j]; } cout << endl; } cout << 180 << endl; rep(i, 8) { rep(j, 8) { cout << v[7 - i][7 - j]; } cout << endl; } cout << 270 << endl; rep(i, 8) { rep(j, 8) { cout << v[i][7 - j]; } cout << endl; } }
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define reep(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) reep((i), 0, (n)) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define EPS 1e-8 #define F first #define S second #define mkp make_pair static const double PI = 6 * asin(0.5); typedef long long ll; typedef complex<double> CP; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; static const int INF = 1 << 24; template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } // v.erase(unique(v.begin(),v.end()),v.end()); int main() { vector<string> v(8); rep(i, 8) { cin >> v[i]; } cout << 90 << endl; rep(i, 8) { rep(j, 8) { cout << v[7 - j][i]; } cout << endl; } cout << 180 << endl; rep(i, 8) { rep(j, 8) { cout << v[7 - i][7 - j]; } cout << endl; } cout << 270 << endl; rep(i, 8) { rep(j, 8) { cout << v[j][7 - i]; } cout << endl; } }
[["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
332
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define all(a) (a).begin(), (a).end() int main(void) { vector<string> buf(8); rep(i, 8) { cin >> buf[i]; } cout << "90" << endl; rep(i, 8) { rep(j, 8) { cout << buf[7 - i][j]; } cout << endl; } cout << "180" << endl; rep(i, 8) { rep(j, 8) { cout << buf[7 - i][7 - j]; } cout << endl; } cout << "270" << endl; rep(i, 8) { rep(j, 8) { cout << buf[i][7 - j]; } cout << endl; } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define all(a) (a).begin(), (a).end() int main(void) { vector<string> buf(8); rep(i, 8) { cin >> buf[i]; } cout << "90" << endl; rep(i, 8) { rep(j, 8) { cout << buf[7 - j][i]; } cout << endl; } cout << "180" << endl; rep(i, 8) { rep(j, 8) { cout << buf[7 - i][7 - j]; } cout << endl; } cout << "270" << endl; rep(i, 8) { rep(j, 8) { cout << buf[j][7 - i]; } cout << endl; } }
[["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
238
#include <iostream> #include <stdio.h> using namespace std; int main() { char c[8][8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c[i][j]; } } cout << "90" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - j][i]; } cout << endl; } cout << "180" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[j][i]; } cout << endl; } cout << "270" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[j][7 - i]; } cout << endl; } return 0; }
#include <iostream> #include <stdio.h> using namespace std; int main() { char c[8][8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> c[i][j]; } } cout << "90" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - j][i]; } cout << endl; } cout << "180" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[7 - i][7 - j]; } cout << endl; } cout << "270" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << c[j][7 - i]; } cout << endl; } return 0; }
[["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 31, 13], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
234
#include <iostream> using namespace std; char x[10][10]; char y[10][10]; void TheRotate90() { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { y[k][7 - j] = x[j][k]; } } } int main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> x[i][j]; } } for (int i = 1; i < 4; i++) { cout << i * 90 << endl; TheRotate90(); for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { x[j][k] = y[j][k]; cout << x[j][k] << endl; } cout << endl; } } return 0; }
#include <iostream> using namespace std; char x[10][10]; char y[10][10]; void TheRotate90() { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { y[k][7 - j] = x[j][k]; } } } int main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> x[i][j]; } } for (int i = 1; i < 4; i++) { cout << i * 90 << endl; TheRotate90(); for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { x[j][k] = y[j][k]; cout << x[j][k]; } cout << endl; } } return 0; }
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
223
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) (r).begin(), (r).end() #define gsort(st, en) sort((st), (en), greater<int>()) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((n)) #define scout(n) cout << setw(n) #define vary(type, name, size, init) vector<type> name(size, init) #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, a, b) for (int i = (a); i < (int)(b); ++i) #define repi(it, array) \ for (auto it = array.begin(), end = array.end(); it != end; ++it) #define repa(n, array) for (auto &n : (array)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; using dict = map<string, int>; using pii = pair<int, int>; constexpr int imax = ((1 << 30) - 1) * 2 + 1; constexpr int inf = 100000000; constexpr double PI = acos(-1.0); double eps = 1e-10; const int dy[] = {-1, 0, 1, 0}; const int dx[] = {0, -1, 0, 1}; inline bool value(int x, int y, int w, int h) { return (x >= 0 && x < w && y >= 0 && y < h); } template <typename T> void Unique(vector<T> &v) { sort(all(v)); v.erase(unique(all(v)), v.end()); } template <typename T> T ston(string &str, T n) { istringstream sin(str); T num; sin >> num; return num; } void Ans(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); char c[8][8]; rep(i, 8) { rep(j, 8) { cin >> c[j][i]; } } cout << 90 << endl; rep(i, 8) { rep(j, 8) { cout << c[j][7 - i]; } cout << endl; } cout << 180 << endl; rep(i, 8) { rep(j, 8) { cout << c[7 - j][7 - i]; } cout << endl; } cout << 270 << endl; rep(i, 8) { rep(j, 8) { cout << c[7 - j][i]; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) (r).begin(), (r).end() #define gsort(st, en) sort((st), (en), greater<int>()) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((n)) #define scout(n) cout << setw(n) #define vary(type, name, size, init) vector<type> name(size, init) #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, a, b) for (int i = (a); i < (int)(b); ++i) #define repi(it, array) \ for (auto it = array.begin(), end = array.end(); it != end; ++it) #define repa(n, array) for (auto &n : (array)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; using dict = map<string, int>; using pii = pair<int, int>; constexpr int imax = ((1 << 30) - 1) * 2 + 1; constexpr int inf = 100000000; constexpr double PI = acos(-1.0); double eps = 1e-10; const int dy[] = {-1, 0, 1, 0}; const int dx[] = {0, -1, 0, 1}; inline bool value(int x, int y, int w, int h) { return (x >= 0 && x < w && y >= 0 && y < h); } template <typename T> void Unique(vector<T> &v) { sort(all(v)); v.erase(unique(all(v)), v.end()); } template <typename T> T ston(string &str, T n) { istringstream sin(str); T num; sin >> num; return num; } void Ans(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); char c[8][8]; rep(i, 8) { rep(j, 8) { cin >> c[j][i]; } } cout << 90 << endl; rep(i, 8) { rep(j, 8) { cout << c[i][7 - j]; } cout << endl; } cout << 180 << endl; rep(i, 8) { rep(j, 8) { cout << c[7 - j][7 - i]; } cout << endl; } cout << 270 << endl; rep(i, 8) { rep(j, 8) { cout << c[7 - i][j]; } cout << endl; } return 0; }
[["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]]
1
542
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define itrep(it, a) for (it = (a).begin(); it != (a).end(); it++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; #define INF (1 << 30) using namespace std; int main() { char a[8][8]; rep(i, 8) rep(j, 8) cin >> a[i][j]; cout << 90 << endl; rep(i, 8) { for (int j = 7; j >= 0; j--) { cout << a[j][i]; } cout << endl; } cout << 180 << endl; for (int i = 7; i >= 0; i--) { for (int j = 7; j >= 0; j--) { cout << a[i][j]; } cout << endl; } cout << 270 << endl; for (int i = 7; i >= 0; i--) { rep(j, 8) { cout << a[i][j]; } cout << endl; } }
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define itrep(it, a) for (it = (a).begin(); it != (a).end(); it++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; #define INF (1 << 30) using namespace std; int main() { char a[8][8]; rep(i, 8) rep(j, 8) cin >> a[i][j]; cout << 90 << endl; rep(i, 8) { for (int j = 7; j >= 0; j--) { cout << a[j][i]; } cout << endl; } cout << 180 << endl; for (int i = 7; i >= 0; i--) { for (int j = 7; j >= 0; j--) { cout << a[i][j]; } cout << endl; } cout << 270 << endl; for (int i = 7; i >= 0; i--) { rep(j, 8) { cout << a[j][i]; } cout << endl; } }
[["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]]
1
227
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s[8]; r(i, 8) cin >> s[i]; cout << 90 << endl; r(i, 8) { r(j, 8) cout << s[7 - i][j]; cout << endl; } cout << 180 << endl; r(i, 8) { r(j, 8) cout << s[7 - i][7 - j]; cout << endl; } cout << 270 << endl; r(i, 8) { r(j, 8) cout << s[i][7 - j]; cout << endl; } }
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s[8]; r(i, 8) cin >> s[i]; cout << 90 << endl; r(i, 8) { r(j, 8) cout << s[7 - j][i]; cout << endl; } cout << 180 << endl; r(i, 8) { r(j, 8) cout << s[7 - i][7 - j]; cout << endl; } cout << 270 << endl; r(i, 8) { r(j, 8) cout << s[j][7 - i]; cout << endl; } }
[["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
153
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-5; typedef long long ll; char pat[8][8]; char rot[8][8]; main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> pat[i][j]; } } for (int i = 1; i <= 3; i++) { cout << i * 90 << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { rot[j][k] = pat[7 - k][j]; cout << rot[j][k]; } cout << endl; } cout << endl; memcpy(pat, rot, sizeof(rot)); } }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; static const double EPS = 1e-5; typedef long long ll; char pat[8][8]; char rot[8][8]; main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cin >> pat[i][j]; } } for (int i = 1; i <= 3; i++) { cout << i * 90 << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { rot[j][k] = pat[7 - k][j]; cout << rot[j][k]; } cout << endl; } memcpy(pat, rot, sizeof(rot)); } }
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
223
#include <cstring> #include <iostream> int main() { char map[8][8], t_m[8][8]; for (int i = 0; i < 8; i++) { std::cin >> map[i]; } for (int i = 1; i < 4; i++) { //ツ角ツ度ツ閉ェ(ツ9ツ0ツ,ツ1ツ8ツ0ツ,ツ2ツ7ツ0)ツ嘉アツ転ツつオツつスツ配ツ療アツづーツ催ャツづゥ for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { t_m[7 - x][y] = map[y][x]; } } memcpy(map, t_m, sizeof(t_m)); std::cout << 90 * i << std::endl; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { std::cout << map[y][x]; } std::cout << "\n"; } } }
#include <cstring> #include <iostream> int main() { char map[8][8], t_m[8][8]; for (int i = 0; i < 8; i++) { std::cin >> map[i]; } for (int i = 1; i < 4; i++) { //ツ角ツ度ツ閉ェ(ツ9ツ0ツ,ツ1ツ8ツ0ツ,ツ2ツ7ツ0)ツ嘉アツ転ツつオツつスツ配ツ療アツづーツ催ャツづゥ for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { t_m[x][7 - y] = map[y][x]; } } memcpy(map, t_m, sizeof(t_m)); std::cout << 90 * i << std::endl; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { std::cout << map[y][x]; } std::cout << "\n"; } } }
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 31, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33]]
1
195
#include <iostream> using namespace std; string b[8]; int main() { for (int i = 0; i < 8; i++) cin >> b[i]; cout << 90 << endl; for (int i = 0; i < 8; i++) { for (int j = 7; j >= 0; j--) { cout << b[i][j]; } cout << endl; } cout << 180 << endl; for (int i = 7; i >= 0; i--) { for (int j = 7; j >= 0; j--) { cout << b[i][j]; } cout << endl; } cout << 270 << endl; for (int i = 7; i >= 0; i--) { for (int j = 0; j < 8; j++) { cout << b[i][j]; } cout << endl; } }
#include <iostream> using namespace std; string b[8]; int main() { for (int i = 0; i < 8; i++) cin >> b[i]; cout << 90 << endl; for (int i = 0; i < 8; i++) { for (int j = 7; j >= 0; j--) { cout << b[j][i]; } cout << endl; } cout << 180 << endl; for (int i = 7; i >= 0; i--) { for (int j = 7; j >= 0; j--) { cout << b[i][j]; } cout << endl; } cout << 270 << endl; for (int i = 7; i >= 0; i--) { for (int j = 0; j < 8; j++) { cout << b[j][i]; } cout << endl; } }
[["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]]
1
195
#include <iostream> using namespace std; int main() { char mat[8][8]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) cin >> mat[i][j]; cout << "90" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[8 - i - 1][j]; } cout << endl; } cout << "180" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[8 - i - 1][8 - j - 1]; } cout << endl; } cout << "270" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[i][8 - j - 1]; } cout << endl; } return 0; }
#include <iostream> using namespace std; int main() { char mat[8][8]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) cin >> mat[i][j]; cout << "90" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[8 - j - 1][i]; } cout << endl; } cout << "180" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[8 - i - 1][8 - j - 1]; } cout << endl; } cout << "270" << endl; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { cout << mat[j][8 - i - 1]; } cout << endl; } return 0; }
[["-", 28, 69, 341, 342, 0, 16, 31, 16, 12, 22], ["+", 28, 69, 341, 342, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 12, 69, 341, 342, 0, 16, 31, 16, 12, 22], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 12, 22]]
1
240
#include <iostream> using namespace std; int func1(int n) { return n; } int func2(int n) { return 7 - n; } void output(char map[][8], int dir) { int angle = dir * 90; int i, j; int *p1, *p2; int (*f1)(int), (*f2)(int); switch (dir) { case 1: f1 = &func2; f2 = &func1; p1 = &j; p2 = &i; break; case 2: f1 = &func2; f2 = &func2; p1 = &i; p2 = &j; break; case 3: f1 = &func1; f2 = &func2; p1 = &j; p2 = &i; break; } cout << angle << endl; for (i = 0; i < 8; ++i) { for (j = 0; j < 8; ++j) { cout << map[f1(i)][f2(j)]; } cout << endl; } } int main() { char map[8][8]; for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) { cin >> map[i][j]; } } output(map, 1); output(map, 2); output(map, 3); return 0; }
#include <iostream> using namespace std; int func1(int n) { return n; } int func2(int n) { return 7 - n; } void output(char map[][8], int dir) { int angle = dir * 90; int i, j; int *p1, *p2; int (*f1)(int), (*f2)(int); switch (dir) { case 1: f1 = &func2; f2 = &func1; p1 = &j; p2 = &i; break; case 2: f1 = &func2; f2 = &func2; p1 = &i; p2 = &j; break; case 3: f1 = &func1; f2 = &func2; p1 = &j; p2 = &i; break; } cout << angle << endl; for (i = 0; i < 8; ++i) { for (j = 0; j < 8; ++j) { cout << map[f1(*p1)][f2(*p2)]; } cout << endl; } } int main() { char map[8][8]; for (int i = 0; i < 8; ++i) { for (int j = 0; j < 8; ++j) { cin >> map[i][j]; } } output(map, 1); output(map, 2); output(map, 3); return 0; }
[["-", 28, 69, 341, 342, 0, 2, 3, 4, 0, 22], ["+", 341, 342, 0, 2, 3, 4, 0, 66, 17, 48], ["+", 341, 342, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 12, 69, 341, 342, 0, 2, 3, 4, 0, 22]]
1
300
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef pair<int, int> pii; const int INF = 1 << 29; const double EPS = 1e-9; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main() { char board[10][10]; rep(i, 8) rep(j, 8) { cin >> board[i][j]; } for (int i = 90; i <= 270; i += 90) { char tmp[10][10]; cout << i << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { tmp[j][k] = board[7 - k][j]; } } rep(j, 8) { rep(k, 8) { cout << tmp[j][k]; } cout << endl; } rep(j, 8) rep(k, 8) board[i][j] = tmp[i][j]; } return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef pair<int, int> pii; const int INF = 1 << 29; const double EPS = 1e-9; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main() { char board[10][10]; rep(i, 8) rep(j, 8) { cin >> board[i][j]; } for (int i = 90; i <= 270; i += 90) { char tmp[10][10]; cout << i << endl; for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { tmp[j][k] = board[7 - k][j]; } } rep(j, 8) { rep(k, 8) { cout << tmp[j][k]; } cout << endl; } rep(j, 8) rep(k, 8) board[j][k] = tmp[j][k]; } return 0; }
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
346
m=[input() for _ in range(8)] for i in range(3): m=list(zip(*m[::-1])) print(90*i) for x in m: print(''.join(x))
m=[input() for _ in range(8)] for i in range(3): m=list(zip(*m[::-1])) print(90*(i+1)) for x in m: print(''.join(x))
[["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 17, 72], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
59
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n").map(Number); var n = Arr.shift(); var sum = 0; for (var i = 0; i < Arr.length; i++) { sum += Arr[i]; } console.log(Math.floor(sum / N));
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n").map(Number); var n = Arr.shift(); var sum = 0; for (var i = 0; i < n; i++) { sum += Arr[i]; } console.log(Math.floor(sum / n));
[["-", 0, 7, 15, 1, 0, 16, 12, 558, 500, 22], ["-", 0, 7, 15, 1, 0, 16, 12, 558, 0, 131], ["-", 0, 7, 15, 1, 0, 16, 12, 558, 559, 560], ["+", 0, 493, 0, 7, 15, 1, 0, 16, 12, 22], ["-", 3, 3, 0, 2, 3, 3, 0, 16, 12, 22], ["+", 3, 3, 0, 2, 3, 3, 0, 16, 12, 22]]
2
97
#include <stdio.h> int main(void) { long long int N; scanf("%lld", &N); int i; long long int sum = 0; for (i = 0; i < N; i++) { int n; scanf("%lld", &n); sum += n; } printf("%lld\n", sum / N); return 0; }
#include <stdio.h> int main(void) { long long int N; scanf("%lld", &N); int i; long long int sum = 0; for (i = 0; i < N; i++) { long long int n; scanf("%lld", &n); sum += n; } printf("%lld\n", sum / N); return 0; }
[["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96]]
0
81
#include <stdio.h> int main(void) { unsigned long long n; unsigned long long num; unsigned long long i; unsigned long long sum; scanf("%lld", &n); sum = 0; for (i = 0; i < num; i++) { scanf("%lld", &num); sum += num; } printf("%lld\n", sum / n); return 0; }
#include <stdio.h> int main(void) { unsigned long long n; unsigned long long num; unsigned long long i; unsigned long long sum; scanf("%lld", &n); sum = 0; for (i = 0; i < n; i++) { scanf("%lld", &num); sum += num; } printf("%lld\n", sum / n); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
0
87
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, e) for (int i = (s); i < (e); i++) #define pb(n) push_back((n)) #define mp(n, m) make_pair((n), (m)) #define all(r) r.begin(), r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int main() { ll n, s = 0, a; cin >> n; rep(i, n) { cin >> a; s += a; } s /= a; cout << s << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, e) for (int i = (s); i < (e); i++) #define pb(n) push_back((n)) #define mp(n, m) make_pair((n), (m)) #define all(r) r.begin(), r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int main() { ll n, s = 0, a; cin >> n; rep(i, n) { cin >> a; s += a; } s /= n; cout << s << endl; }
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
172
#include <stdio.h> int n, a; long long s; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a), s += a; printf("%lld\n", s / a); return 0; }
#include <stdio.h> int n, a; long long s; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a), s += a; printf("%lld\n", s / n); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
70
#include <iostream> using namespace std; int main() { int n; int p[9][9]; char map[9][9]; int check[10]; cin >> n; while (n) { n--; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { cin >> p[i][j]; map[i][j] = ' '; } } for (int i = 0; i < 9; i++) { for (int j = 1; j < 10; j++) check[j] = 0; for (int j = 0; j < 9; j++) check[p[i][j]]++; for (int j = 0; j < 9; j++) { if (check[p[i][j]] > 1) map[i][j] = '*'; } } for (int i = 0; i < 9; i++) { for (int j = 1; j < 10; j++) check[j] = 0; for (int j = 0; j < 9; j++) check[p[j][i]]++; for (int j = 0; j < 9; j++) { if (check[p[j][i]] > 1) map[j][i] = '*'; } } for (int i = 0; i < 9; i += 3) { for (int j = 0; j < 9; j += 3) { for (int k = 1; k < 10; k++) check[k] = 0; for (int k = i; k < i + 3; k++) { for (int l = j; l < j + 3; l++) check[p[k][l]]++; } for (int k = i; k < i + 3; k++) { for (int l = j; l < j + 3; l++) { if (check[p[k][l]] > 1) map[k][l] = '*'; } } } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { cout << map[i][j] << p[i][j]; } cout << endl; } cout << endl; } }
#include <iostream> using namespace std; int main() { int n; int p[9][9]; char map[9][9]; int check[10]; cin >> n; while (n) { n--; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { cin >> p[i][j]; map[i][j] = ' '; } } for (int i = 0; i < 9; i++) { for (int j = 1; j < 10; j++) check[j] = 0; for (int j = 0; j < 9; j++) check[p[i][j]]++; for (int j = 0; j < 9; j++) { if (check[p[i][j]] > 1) map[i][j] = '*'; } } for (int i = 0; i < 9; i++) { for (int j = 1; j < 10; j++) check[j] = 0; for (int j = 0; j < 9; j++) check[p[j][i]]++; for (int j = 0; j < 9; j++) { if (check[p[j][i]] > 1) map[j][i] = '*'; } } for (int i = 0; i < 9; i += 3) { for (int j = 0; j < 9; j += 3) { for (int k = 1; k < 10; k++) check[k] = 0; for (int k = i; k < i + 3; k++) { for (int l = j; l < j + 3; l++) check[p[k][l]]++; } for (int k = i; k < i + 3; k++) { for (int l = j; l < j + 3; l++) { if (check[p[k][l]] > 1) map[k][l] = '*'; } } } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { cout << map[i][j] << p[i][j]; } cout << endl; } if (n) cout << endl; } }
[["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25]]
1
540