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
| change_count
int64 0
100
|
|---|---|---|---|---|---|
#include <iostream>
using namespace std;
char field[14][14]; // 3~10
void bomb(int y, int x) {
field[y][x] = '0';
for (int i = -3; i <= 3; i++) {
if (field[y][x + i] == '1')
bomb(y, x + i);
if (field[y + i][x] == '1')
bomb(y + i, x);
}
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 14; j++) {
for (int k = 0; k < 14; k++) {
field[j][k] = '0';
}
}
for (int j = 3; j <= 10; j++) {
for (int k = 3; k <= 10; k++) {
cin >> field[j][k];
}
}
int x, y;
cin >> x >> y;
bomb(y + 3 - 1, x + 3 - 1);
cout << "Data" << i << ":" << endl;
for (int j = 3; j <= 10; j++) {
for (int k = 3; k <= 10; k++) {
cout << field[j][k];
}
cout << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
char field[14][14]; // 3~10
void bomb(int y, int x) {
field[y][x] = '0';
for (int i = -3; i <= 3; i++) {
if (field[y][x + i] == '1')
bomb(y, x + i);
if (field[y + i][x] == '1')
bomb(y + i, x);
}
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 14; j++) {
for (int k = 0; k < 14; k++) {
field[j][k] = '0';
}
}
for (int j = 3; j <= 10; j++) {
for (int k = 3; k <= 10; k++) {
cin >> field[j][k];
}
}
int x, y;
cin >> x >> y;
bomb(y + 3 - 1, x + 3 - 1);
cout << "Data " << i << ":" << endl;
for (int j = 3; j <= 10; j++) {
for (int k = 3; k <= 10; k++) {
cout << field[j][k];
}
cout << endl;
}
}
return 0;
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 309
| 2
|
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int dx[] = {-3, -2, -1, 0, 0, 0, 1, 2, 3, 0, 0, 0};
int dy[] = {0, 0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3};
char mas[8][8];
void solve(int, int);
int main() {
int n, x, y, HM = 1;
cin >> n;
while (n--) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> mas[i][j];
}
}
cin >> y >> x;
solve(x - 1, y - 1);
cout << "Data " << HM << endl;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cout << mas[i][j];
}
cout << endl;
}
HM++;
}
}
void solve(int x, int y) {
mas[x][y] = '0';
for (int i = 0; i < 12; i++) {
int nx = dx[i] + x, ny = dy[i] + y;
if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && mas[nx][ny] == '1') {
solve(nx, ny);
}
}
}
|
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int dx[] = {-3, -2, -1, 0, 0, 0, 1, 2, 3, 0, 0, 0};
int dy[] = {0, 0, 0, 1, 2, 3, 0, 0, 0, -1, -2, -3};
char mas[8][8];
void solve(int, int);
int main() {
int n, x, y, HM = 1;
cin >> n;
while (n--) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> mas[i][j];
}
}
cin >> y >> x;
solve(x - 1, y - 1);
cout << "Data " << HM << ":" << endl;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cout << mas[i][j];
}
cout << endl;
}
HM++;
}
}
void solve(int x, int y) {
mas[x][y] = '0';
for (int i = 0; i < 12; i++) {
int nx = dx[i] + x, ny = dy[i] + y;
if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && mas[nx][ny] == '1') {
solve(nx, ny);
}
}
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151]]
| 1
| 332
| 4
|
/*
0071:Bombs Chain
*/
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
char map[8][8];
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};
void bomb(int sx, int sy);
int main(void) {
int dt;
cin >> dt;
for (int s = 0; s < dt; s++) {
int sx, sy;
cout << endl;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
char c;
cin >> c;
map[i][j] = c;
}
}
cin >> sy >> sx;
bomb(sx - 1, sy - 1);
cout << "Data " << s + 1 << ":" << endl;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cout << map[i][j];
}
cout << endl;
}
}
return 0;
}
void bomb(int sx, int sy) {
queue<P> que;
que.push(P(sx, sy));
map[sx][sy] = '0';
while (que.size()) {
P point = que.front();
que.pop();
for (int i = 0; i < 4; i++) {
for (int j = 1; j < 4; j++) {
int nx = point.first + vx[i] * j;
int ny = point.second + vy[i] * j;
if (8 > nx && nx >= 0 && 8 > ny && ny >= 0) {
if (map[nx][ny] == '1') {
que.push(P(nx, ny));
map[nx][ny] = '0';
}
}
}
}
}
}
|
/*
0071:Bombs Chain
*/
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
char map[8][8];
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};
void bomb(int sx, int sy);
int main(void) {
int dt;
cin >> dt;
for (int s = 0; s < dt; s++) {
int sx, sy;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
char c;
cin >> c;
map[i][j] = c;
}
}
cin >> sy >> sx;
bomb(sx - 1, sy - 1);
cout << "Data " << s + 1 << ":" << endl;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cout << map[i][j];
}
cout << endl;
}
}
return 0;
}
void bomb(int sx, int sy) {
queue<P> que;
que.push(P(sx, sy));
map[sx][sy] = '0';
while (que.size()) {
P point = que.front();
que.pop();
for (int i = 0; i < 4; i++) {
for (int j = 1; j < 4; j++) {
int nx = point.first + vx[i] * j;
int ny = point.second + vy[i] * j;
if (8 > nx && nx >= 0 && 8 > ny && ny >= 0) {
if (map[nx][ny] == '1') {
que.push(P(nx, ny));
map[nx][ny] = '0';
}
}
}
}
}
}
|
[["-", 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
| 427
| 4
|
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
bool field[8][8];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void bomb(int x, int y) {
field[x][y] = false;
REP(i, 4) {
for (int j = 1; j <= 3; j++) {
int tx = x + dx[i] * j;
int ty = y + dy[i] * j;
if (tx < 0 || ty < 0 || tx == 8 || ty == 8)
continue;
if (field[tx][ty])
bomb(tx, ty);
}
}
}
int main() {
int n, x, y;
string str;
cin >> n;
REP(i, n) {
getline(cin, str);
REP(j, 8) {
cin >> str;
REP(k, 8) {
if (str[k] == '0')
field[j][k] = false;
else
field[j][k] = true;
}
}
cin >> y >> x;
bomb(x - 1, y - 1);
cout << "Data " << i + 1 << ":\n";
REP(j, 8) {
REP(k, 8) { cout << field[j][k]; }
cout << endl;
}
}
}
|
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
bool field[8][8];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void bomb(int x, int y) {
field[x][y] = false;
REP(i, 4) {
for (int j = 1; j <= 3; j++) {
int tx = x + dx[i] * j;
int ty = y + dy[i] * j;
if (tx < 0 || ty < 0 || tx > 7 || ty > 7)
continue;
if (field[tx][ty])
bomb(tx, ty);
}
}
}
int main() {
int n, x, y;
string str;
cin >> n;
REP(i, n) {
getline(cin, str);
REP(j, 8) {
cin >> str;
REP(k, 8) {
if (str[k] == '0')
field[j][k] = false;
else
field[j][k] = true;
}
}
cin >> y >> x;
bomb(x - 1, y - 1);
cout << "Data " << i + 1 << ":\n";
REP(j, 8) {
REP(k, 8) { cout << field[j][k]; }
cout << endl;
}
}
}
|
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 60], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 47], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 574
| 8
|
s=gets.to_i
for i in 1..s
num=[]
8.times do
num<<gets.chomp.split(//).map(&:to_i)
end
x=gets.to_i-1
y=gets.to_i-1
check=[x,y]
until check.empty?
y=check.pop
x=check.pop
(-3).upto(3) do |t|
if (x+t)<8 && 0<=(x+t) && num[y][x+t]==1
check<<(x+t).to_i
check<<y.to_i
num[y][x+t]=0
end
if (y+t)<8 && 0<=(y+t) && num[y+t][x]==1
check<<x.to_i
check<<(y+t).to_i
num[y+t][x]=0
end
end
end
puts "Data #{i}:"
8.times{ |t| puts num[t].join}
end
|
s=gets.to_i
for i in 1..s
gets.chomp
num=[]
8.times do
num<<gets.chomp.split(//).map(&:to_i)
end
x=gets.to_i-1
y=gets.to_i-1
check=[x,y]
until check.empty?
y=check.pop
x=check.pop
(-3).upto(3) do |t|
if (x+t)<8 && 0<=(x+t) && num[y][x+t]==1
check<<(x+t).to_i
check<<y.to_i
num[y][x+t]=0
end
if (y+t)<8 && 0<=(y+t) && num[y+t][x]==1
check<<x.to_i
check<<(y+t).to_i
num[y+t][x]=0
end
end
end
puts "Data #{i}:"
8.times{ |t| puts num[t].join}
end
|
[["+", 36, 36, 36, 36, 0, 42, 0, 652, 486, 22], ["+", 36, 36, 36, 36, 0, 42, 0, 652, 17, 131], ["+", 36, 36, 36, 36, 0, 42, 0, 652, 735, 22]]
| 4
| 41
| 3
|
#!/usr/bin/env ruby
def bomb(x, y)
return if @field[x][y] != 1
@field[x][y] = 0
-3.upto(3) do |i|
next if i.zero?
bomb(x + i, y) if (x + i) >= 0 && (x + i) < 8
bomb(x, y + i) if (y + i) >= 0 && (y + i) < 8
end
end
n = gets.chomp!.to_i
# skip empty line
gets
n.times do |i|
@field = []
8.times do |r|
@field[r] = gets.chomp!.split('').map(&:to_i)
end
bomb_x = gets.chomp!.to_i
bomb_y = gets.chomp!.to_i
# simulate bomb
bomb(bomb_x - 1, bomb_y - 1)
# output result
puts "Data #{i + 1}:"
8.times do |r|
puts @field[r].join('')
end
# skip empty-line
gets if i + 1 != n
end
|
#!/usr/bin/env ruby
def bomb(x, y)
return if @field[x][y] != 1
@field[x][y] = 0
-3.upto(3) do |i|
next if i.zero?
bomb(x + i, y) if (x + i) >= 0 && (x + i) < 8
bomb(x, y + i) if (y + i) >= 0 && (y + i) < 8
end
end
n = gets.chomp!.to_i
# skip empty line
gets
n.times do |i|
@field = []
8.times do |r|
@field[r] = gets.chomp!.split('').map(&:to_i)
end
bomb_x = gets.chomp!.to_i
bomb_y = gets.chomp!.to_i
# simulate bomb
bomb(bomb_y - 1, bomb_x - 1)
# output result
puts "Data #{i + 1}:"
8.times do |r|
puts @field[r].join('')
end
# skip empty-line
gets if i + 1 != n
end
|
[["-", 8, 736, 0, 652, 3, 4, 0, 738, 31, 22], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 31, 22]]
| 4
| 206
| 4
|
def solve(data,p):
L=[]
if data[p[1]-1][p[0]-1]=="1":
data[p[1]-1]=data[p[1]-1][:p[0]-1]+"0"+data[p[1]-1][p[0]:]
L+=p
else:
return []
bakuhu=[(p[0]-3,p[1]),(p[0]-2,p[1]),(p[0]-1,p[1]),(p[0]+1,p[1]),(p[0]+2,p[1]),(p[0]+3,p[1]),(p[0],p[1]-3),(p[0],p[1]-2),(p[0],p[1]-1),(p[0],p[1]+1),(p[0],p[1]+2),(p[0],p[1]+3)]
for i in range(len(bakuhu)):
if bakuhu[i][0]>0 and bakuhu[i][1] >0 and bakuhu[i][0] <9 and bakuhu[i][1] <9:
L.extend(solve(data,bakuhu[i]))
return L
while True:
try:
ndata=eval(input())
for i in range(ndata):
input()
data=[]
for j in range(8):
data.append(input())
x=eval(input())
y=eval(input())
p=(x,y)
L=solve(data,p)
while len(L)!=0:
x=L.pop(0)
y=L.pop(0)
data[y-1]=data[y-1][:x-1]+'0'+data[y-1][x:]
print("Data"+str(i+1)+':')
for i in range(len(data)):
print(data[i])
except:
break
|
def solve(data,p):
L=[]
if data[p[1]-1][p[0]-1]=="1":
data[p[1]-1]=data[p[1]-1][:p[0]-1]+"0"+data[p[1]-1][p[0]:]
L+=p
else:
return []
bakuhu=[(p[0]-3,p[1]),(p[0]-2,p[1]),(p[0]-1,p[1]),(p[0]+1,p[1]),(p[0]+2,p[1]),(p[0]+3,p[1]),(p[0],p[1]-3),(p[0],p[1]-2),(p[0],p[1]-1),(p[0],p[1]+1),(p[0],p[1]+2),(p[0],p[1]+3)]
for i in range(len(bakuhu)):
if bakuhu[i][0]>0 and bakuhu[i][1] >0 and bakuhu[i][0] <9 and bakuhu[i][1] <9:
L.extend(solve(data,bakuhu[i]))
return L
while True:
try:
ndata=eval(input())
for i in range(ndata):
input()
data=[]
for j in range(8):
data.append(input())
x=eval(input())
y=eval(input())
p=(x,y)
L=solve(data,p)
while len(L)!=0:
x=L.pop(0)
y=L.pop(0)
data[y-1]=data[y-1][:x-1]+'0'+data[y-1][x:]
print("Data "+str(i+1)+':')
for i in range(len(data)):
print(data[i])
except:
break
|
[["-", 3, 4, 0, 657, 31, 657, 31, 557, 0, 6], ["+", 3, 4, 0, 657, 31, 657, 31, 557, 0, 6]]
| 5
| 502
| 2
|
def bomb(f,x,y):
rf=f[:][:]
rf[y][x]=0
for i in [-3,-2,-1,1,2,3]:
if 0<=x+i<=7:
if rf[y][x+i]==1:
rf=bomb(rf,x+i,y)
if 0<=y+i<=7:
if rf[y+i][x]==1:
rf=bomb(rf,x,y+i)
return rf
n=int(input())
for data in range(1,n+1):
input()
f=[]
for i in range(8):
l.append([int(x) for x in input()])
x=int(input())-1
y=int(input())-1
# map(int,raw_input().split())
f=bomb(f,x,y)
print("Data %d:"%(data))
for i in range(8):
print(''.join(map(str, f[i])))
|
def bomb(f,x,y):
rf=f[:][:]
rf[y][x]=0
for i in [-3,-2,-1,1,2,3]:
if 0<=x+i<=7:
if rf[y][x+i]==1:
rf=bomb(rf,x+i,y)
if 0<=y+i<=7:
if rf[y+i][x]==1:
rf=bomb(rf,x,y+i)
return rf
n=int(input())
for data in range(1,n+1):
input()
f=[]
for i in range(8):
f.append([int(x) for x in input()])
x=int(input())-1
y=int(input())-1
# map(int,raw_input().split())
f=bomb(f,x,y)
print("Data %d:"%(data))
for i in range(8):
print(''.join(map(str, f[i])))
|
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22]]
| 5
| 237
| 2
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0071
"""
import sys
def check_bombs(map, pos, dir, range=3):
"""
????¢¨????±???????????????\??????????????????????????§???????????????
(?????°????????????????¢¨????±??????´?????§????????????????????????????????????????????§????????????????????????)
:param map: ?????¨?????¶???
:param pos: ???????????????????????????
:param dir: ?????§????????????????¢¨????????? (up, down, left, right)
:param range: ????¢¨????±??????????
:return: ???????????????????????????????????? or None
"""
if dir == 'up':
x, y = pos
while range > 0 and y > 0:
if map[y-1][x] == '1':
return (x, y-1)
else:
y -= 1
range -= 1
elif dir == 'down':
x, y = pos
while range > 0 and y < len(map)-1:
if map[y+1][x] == '1':
return (x, y+1)
else:
y += 1
range -= 1
elif dir == 'left':
x, y = pos
while range > 0 and x > 0:
if map[y][x-1] == '1':
return (x-1, y)
else:
x -= 1
range -= 1
elif dir == 'right':
x, y = pos
while range > 0 and x < len(map[0])-1:
if map[y][x+1] == '1':
return (x+1, y)
else:
x += 1
range -= 1
else:
return None
def chain_bombs(map, init_pos):
"""
???????????£?????????????????¶???????¨??????????
:param map: ???????????????????????¶???
:param init_pos: (0, 0)?????????????????????????????????????????????????????§?¨?
:return: ??????????????????????????¶???
"""
lmap = map[:] # ??????????????¶????¨??????¨
detonated = [init_pos] # ??±?????????????????????????????????(????????????)
while detonated:
x, y = detonated.pop()
lmap[y][x] = '0'
res = check_bombs(lmap, (x, y), 'up')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'down')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'left')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'right')
if res:
detonated.append(res)
return lmap
def main(args):
data_set = int(input())
maps = []
init_pos = []
for i in range(data_set):
_ = input()
maps.append([list(input().strip()) for _ in range(8)])
init_pos.append([int(input())-1, int(input())-1]) # ??§?¨????0???????????????????????????
count = 1
for map, pos in zip(maps, init_pos):
result = chain_bombs(map, pos)
print('Data {}:'.format(count))
for row in result:
print(''.join(row))
if __name__ == '__main__':
main(sys.argv[1:])
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0071
"""
import sys
def check_bombs(map, pos, dir, range=3):
"""
????¢¨????±???????????????\??????????????????????????§???????????????
(?????°????????????????¢¨????±??????´?????§????????????????????????????????????????????§????????????????????????)
:param map: ?????¨?????¶???
:param pos: ???????????????????????????
:param dir: ?????§????????????????¢¨????????? (up, down, left, right)
:param range: ????¢¨????±??????????
:return: ???????????????????????????????????? or None
"""
if dir == 'up':
x, y = pos
while range > 0 and y > 0:
if map[y-1][x] == '1':
return (x, y-1)
else:
y -= 1
range -= 1
elif dir == 'down':
x, y = pos
while range > 0 and y < len(map)-1:
if map[y+1][x] == '1':
return (x, y+1)
else:
y += 1
range -= 1
elif dir == 'left':
x, y = pos
while range > 0 and x > 0:
if map[y][x-1] == '1':
return (x-1, y)
else:
x -= 1
range -= 1
elif dir == 'right':
x, y = pos
while range > 0 and x < len(map[0])-1:
if map[y][x+1] == '1':
return (x+1, y)
else:
x += 1
range -= 1
else:
return None
def chain_bombs(map, init_pos):
"""
???????????£?????????????????¶???????¨??????????
:param map: ???????????????????????¶???
:param init_pos: (0, 0)?????????????????????????????????????????????????????§?¨?
:return: ??????????????????????????¶???
"""
lmap = map[:] # ??????????????¶????¨??????¨
detonated = [init_pos] # ??±?????????????????????????????????(????????????)
while detonated:
x, y = detonated.pop()
lmap[y][x] = '0'
res = check_bombs(lmap, (x, y), 'up')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'down')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'left')
if res:
detonated.append(res)
res = check_bombs(lmap, (x, y), 'right')
if res:
detonated.append(res)
return lmap
def main(args):
data_set = int(input())
maps = []
init_pos = []
for i in range(data_set):
_ = input()
maps.append([list(input().strip()) for _ in range(8)])
init_pos.append([int(input())-1, int(input())-1]) # ??§?¨????0???????????????????????????
count = 1
for map, pos in zip(maps, init_pos):
result = chain_bombs(map, pos)
print('Data {}:'.format(count))
for row in result:
print(''.join(row))
count += 1
if __name__ == '__main__':
main(sys.argv[1:])
|
[["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612]]
| 5
| 547
| 3
|
def e(x,y):
A[y][x]='0'
for dx,dy in[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)
for i in range(int(input())):
print(f'Data {i+1}')
input()
A=[list(input())for _ in[0]*8]
e(int(input())-1,int(input())-1)
for r in A:print(*r,sep='')
|
def e(x,y):
A[y][x]='0'
for dx,dy in[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)
for i in range(int(input())):
print(f'Data {i+1}:')
input()
A=[list(input())for _ in[0]*8]
e(int(input())-1,int(input())-1)
for r in A:print(*r,sep='')
|
[["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
| 5
| 227
| 11
|
#!/usr/bin/env python
# coding: utf-8
import sys
def board_to_string(board):
return "\n".join(["".join([str(i) for i in row]) for row in board])
def get_answer(board, positions):
x, y = positions.pop(0)
board[y][x] = 0
explode_range = []
for i in [j for j in range(-3, 4) if j]:
if (0 <= (x + i) <= 7):
explode_range.append((x + i, y))
if (0 <= (y + i) <= 7):
explode_range.append((x, y + i))
for explode_pos in explode_range:
x, y = explode_pos
if board[y][x] == 1:
board[y][x] = 0
positions.append((x, y))
if positions:
return get_answer(board, positions)
else:
return board
def main():
s = sys.stdin.read()
params = [param.rstrip() for param in s.split("\n\n")][1:]
for i, param in enumerate(params):
print("Data %d:" % (i + 1))
lines = param.split("\n")
board = [list(map(int, line)) for line in lines[:-2]]
x, y = list(map(int, lines[-2:]))
x -= 1
y -= 1
positions = []
positions.append((x, y))
print(positions)
ans_board = get_answer(board, positions)
print(board_to_string(ans_board))
if __name__ == '__main__':
main()
|
#!/usr/bin/env python
# coding: utf-8
import sys
def board_to_string(board):
return "\n".join(["".join([str(i) for i in row]) for row in board])
def get_answer(board, positions):
x, y = positions.pop(0)
board[y][x] = 0
explode_range = []
for i in [j for j in range(-3, 4) if j]:
if (0 <= (x + i) <= 7):
explode_range.append((x + i, y))
if (0 <= (y + i) <= 7):
explode_range.append((x, y + i))
for explode_pos in explode_range:
x, y = explode_pos
if board[y][x] == 1:
board[y][x] = 0
positions.append((x, y))
if positions:
return get_answer(board, positions)
else:
return board
def main():
s = sys.stdin.read()
params = [param.rstrip() for param in s.split("\n\n")][1:]
for i, param in enumerate(params):
print("Data %d:" % (i + 1))
lines = param.split("\n")
board = [list(map(int, line)) for line in lines[:-2]]
x, y = list(map(int, lines[-2:]))
x -= 1
y -= 1
positions = []
positions.append((x, y))
ans_board = get_answer(board, positions)
print(board_to_string(ans_board))
if __name__ == '__main__':
main()
|
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
| 5
| 354
| 4
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
static int V;
static int E;
static Edge[] es;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
V = n;
int m = sc.nextInt();
E = m;
es = new Edge[E];
for (int i = 0; i < m; i++) {
String[] tmp = sc.next().split(",");
int a = Integer.parseInt(tmp[0]);
int b = Integer.parseInt(tmp[1]);
int c = Integer.parseInt(tmp[2]);
es[i] = new Edge(a, b, c);
}
int ret = kruskal();
ret -= (n - 1) * 100;
out.println(ret / 100);
}
}
public static int kruskal() {
Arrays.sort(es, new Comp());
init(V);
int res = 0;
for (int i = 0; i < E; i++) {
Edge e = es[i];
if (!same(e.u, e.v)) {
unite(e.u, e.v);
res += e.cost;
}
}
return res;
}
static int[] par;
static int[] rank;
static void init(int n) {
par = new int[V];
rank = new int[V];
for (int i = 0; i < n; i++) {
par[i] = i;
rank[i] = 0;
}
}
static int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
static void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y]) {
par[x] = y;
} else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
}
static boolean same(int x, int y) { return find(x) == find(y); }
}
class Edge {
int u;
int v;
int cost;
Edge(int a, int b, int c) {
u = a;
v = b;
cost = c;
}
}
class Comp implements Comparator<Edge> {
public int compare(Edge o1, Edge o2) { return o1.cost - o2.cost; }
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
static int V;
static int E;
static Edge[] es;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
V = n;
int m = sc.nextInt();
E = m;
es = new Edge[E];
for (int i = 0; i < m; i++) {
String[] tmp = sc.next().split(",");
int a = Integer.parseInt(tmp[0]);
int b = Integer.parseInt(tmp[1]);
int c = Integer.parseInt(tmp[2]);
es[i] = new Edge(a, b, c);
}
int ret = kruskal();
ret -= (n - 1) * 100;
out.println(ret / 100);
}
out.flush();
}
public static int kruskal() {
Arrays.sort(es, new Comp());
init(V);
int res = 0;
for (int i = 0; i < E; i++) {
Edge e = es[i];
if (!same(e.u, e.v)) {
unite(e.u, e.v);
res += e.cost;
}
}
return res;
}
static int[] par;
static int[] rank;
static void init(int n) {
par = new int[V];
rank = new int[V];
for (int i = 0; i < n; i++) {
par[i] = i;
rank[i] = 0;
}
}
static int find(int x) {
if (par[x] == x) {
return x;
} else {
return par[x] = find(par[x]);
}
}
static void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y]) {
par[x] = y;
} else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
}
static boolean same(int x, int y) { return find(x) == find(y); }
}
class Edge {
int u;
int v;
int cost;
Edge(int a, int b, int c) {
u = a;
v = b;
cost = c;
}
}
class Comp implements Comparator<Edge> {
public int compare(Edge o1, Edge o2) { return o1.cost - o2.cost; }
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 0, 131], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["+", 8, 498, 0, 195, 8, 196, 0, 1, 0, 35]]
| 3
| 1,061
| 6
|
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
int m = sc.nextInt();
sc.useDelimiter(",|\r\n");
Edge[] es = new Edge[m];
UnionFind uf = new UnionFind(n);
for (int i = 0; i < m; i++) {
int s = sc.nextInt();
int e = sc.nextInt();
int d = sc.nextInt();
es[i] = new Edge(s, e, d);
}
Arrays.sort(es, new Comparator<Edge>() {
public int compare(Edge a, Edge b) { return a.d - b.d; }
});
int sum = 0;
for (int i = 0; i < m; i++) {
int a = es[i].s;
int b = es[i].e;
int d = es[i].d;
if (!uf.same(a, b)) {
uf.unite(a, b);
sum += d / 100 - 1;
}
}
System.out.println(sum);
}
}
}
class Edge {
public int s;
public int e;
public int d;
Edge(int s, int e, int d) {
this.s = s;
this.e = e;
this.d = d;
}
}
class UnionFind {
public int par[];
public int rank[];
UnionFind(int n) {
par = new int[n];
rank = new int[n];
for (int i = 0; i < n; i++) {
par[i] = i;
}
}
public int find(int x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
public void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y]) {
par[x] = y;
} else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
}
public boolean same(int x, int y) { return find(x) == find(y); }
}
|
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
int m = sc.nextInt();
sc.useDelimiter(",|\n");
Edge[] es = new Edge[m];
UnionFind uf = new UnionFind(n);
for (int i = 0; i < m; i++) {
int s = sc.nextInt();
int e = sc.nextInt();
int d = sc.nextInt();
es[i] = new Edge(s, e, d);
}
Arrays.sort(es, new Comparator<Edge>() {
public int compare(Edge a, Edge b) { return a.d - b.d; }
});
int sum = 0;
for (int i = 0; i < m; i++) {
int a = es[i].s;
int b = es[i].e;
int d = es[i].d;
if (!uf.same(a, b)) {
uf.unite(a, b);
sum += d / 100 - 1;
}
}
System.out.println(sum);
}
}
}
class Edge {
public int s;
public int e;
public int d;
Edge(int s, int e, int d) {
this.s = s;
this.e = e;
this.d = d;
}
}
class UnionFind {
public int par[];
public int rank[];
UnionFind(int n) {
par = new int[n];
rank = new int[n];
for (int i = 0; i < n; i++) {
par[i] = i;
}
}
public int find(int x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
public void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)
return;
if (rank[x] < rank[y]) {
par[x] = y;
} else {
par[y] = x;
if (rank[x] == rank[y])
rank[x]++;
}
}
public boolean same(int x, int y) { return find(x) == find(y); }
}
|
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
| 3
| 552
| 1
|
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
final int INF = 1 << 30;
int adjacent[][];
Scanner sc;
int n;
int solve() {
int cost = 0;
Set<Integer> vertex = new HashSet<Integer>();
vertex.add(0);
for (int h = 0; h < n; ++h) {
int min = INF, e = 0;
for (int v : vertex) {
for (int i = 0; i < n; ++i) {
if (vertex.contains(i))
continue;
if (adjacent[v][i] < min) {
min = adjacent[v][i];
e = i;
}
}
}
if (min < INF) {
vertex.add(e);
cost += min / 100 - 1;
}
}
return cost;
}
int ni() { return sc.nextInt(); }
void io() {
sc = new Scanner(System.in).useDelimiter("\\s*,\\s*|\r\n");
while ((n = ni()) != 0) {
adjacent = new int[n][n];
for (int i = 0; i < n; ++i) {
Arrays.fill(adjacent[i], INF);
}
int m = ni();
for (int i = 0; i < m; ++i) {
int a = ni(), b = ni(), d = ni();
adjacent[a][b] = adjacent[b][a] = d;
}
System.out.println(solve());
}
}
public static void main(String[] args) { new Main().io(); }
}
|
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
final int INF = 1 << 30;
int adjacent[][];
Scanner sc;
int n;
int solve() {
int cost = 0;
Set<Integer> vertex = new HashSet<Integer>();
vertex.add(0);
for (int h = 0; h < n; ++h) {
int min = INF, e = 0;
for (int v : vertex) {
for (int i = 0; i < n; ++i) {
if (vertex.contains(i))
continue;
if (adjacent[v][i] < min) {
min = adjacent[v][i];
e = i;
}
}
}
if (min < INF) {
vertex.add(e);
cost += min / 100 - 1;
}
}
return cost;
}
int ni() { return sc.nextInt(); }
void io() {
sc = new Scanner(System.in).useDelimiter("\\s*,\\s*|\n");
while ((n = ni()) != 0) {
adjacent = new int[n][n];
for (int i = 0; i < n; ++i) {
Arrays.fill(adjacent[i], INF);
}
int m = ni();
for (int i = 0; i < m; ++i) {
int a = ni(), b = ni(), d = ni();
adjacent[a][b] = adjacent[b][a] = d;
}
System.out.println(solve());
}
}
public static void main(String[] args) { new Main().io(); }
}
|
[["-", 0, 11, 12, 492, 3, 4, 0, 5, 0, 44]]
| 3
| 387
| 1
|
#include <algorithm>
#include <ios>
#include <iostream>
#include <vector>
using namespace std;
#include <vector>
struct UF {
int n;
vector<int> parent, rank;
UF(int n_ = 0) : n(n_), parent(n_), rank(n_, 0) {
for (int i = 0; i < n_; i++)
parent[i] = i;
}
int find(int a) { return parent[a] != a ? parent[a] = find(parent[a]) : a; }
bool same(int a, int b) { return find(a) == find(b); }
bool unite(int a, int b) {
a = find(a), b = find(b);
if (a == b)
return false;
if (rank[a] < rank[b]) {
parent[a] = b;
} else {
parent[b] = a;
if (rank[a] == rank[b])
rank[a]++;
}
return true;
}
};
main() {
int n;
while (cin >> n, n) {
int m;
cin >> m;
int ans = n;
vector<pair<int, pair<int, int>>> e;
for (; m--;) {
int a, b, c;
scanf("%d,%d,%d", &a, &b, &c);
c = c / 100 - 1;
e.push_back(make_pair(c, make_pair(a, b)));
}
UF uf(n);
sort(e.begin(), e.end());
for (int i = 0; i < e.size(); i++) {
int a = e[i].second.first, b = e[i].second.second, c = e[i].first;
if (uf.same(a, b))
continue;
uf.unite(a, b);
ans += c;
}
cout << ans << endl;
}
}
|
#include <algorithm>
#include <ios>
#include <iostream>
#include <vector>
using namespace std;
#include <vector>
struct UF {
int n;
vector<int> parent, rank;
UF(int n_ = 0) : n(n_), parent(n_), rank(n_, 0) {
for (int i = 0; i < n_; i++)
parent[i] = i;
}
int find(int a) { return parent[a] != a ? parent[a] = find(parent[a]) : a; }
bool same(int a, int b) { return find(a) == find(b); }
bool unite(int a, int b) {
a = find(a), b = find(b);
if (a == b)
return false;
if (rank[a] < rank[b]) {
parent[a] = b;
} else {
parent[b] = a;
if (rank[a] == rank[b])
rank[a]++;
}
return true;
}
};
main() {
int n;
while (cin >> n, n) {
int m;
cin >> m;
int ans = 0;
vector<pair<int, pair<int, int>>> e;
for (; m--;) {
int a, b, c;
scanf("%d,%d,%d", &a, &b, &c);
c = c / 100 - 1;
e.push_back(make_pair(c, make_pair(a, b)));
}
UF uf(n);
sort(e.begin(), e.end());
for (int i = 0; i < e.size(); i++) {
int a = e[i].second.first, b = e[i].second.second, c = e[i].first;
if (uf.same(a, b))
continue;
uf.unite(a, b);
ans += c;
}
cout << ans << endl;
}
}
|
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
| 1
| 424
| 2
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n) \
cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define foreach(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
struct Edge {
int src, dst, weight;
Edge() {}
Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
bool operator<(const Edge &lhs, const Edge &rhs) {
return lhs.weight < rhs.weight;
}
bool operator>(const Edge &lhs, const Edge &rhs) {
return lhs.weight > rhs.weight;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
struct UnionFind {
vi data;
UnionFind(int size) : data(size, -1) {}
int Find(int n) { return data[n] < 0 ? n : (data[n] = Find(data[n])); }
void Union(int n1, int n2) {
int d1 = Find(n1);
int d2 = Find(n2);
if (d1 != d2) {
if (-data[d1] < -data[d2])
swap(d1, d2);
data[d1] += data[d2];
data[d2] = d1;
}
}
int Size(int n) { return -data[Find(n)]; }
};
int Kruskal(Graph &g, Edges &e) {
e.clear();
UnionFind uf(g.size());
set<Edge> s;
rep(i, g.size()) rep(j, g[i].size()) s.insert(g[i][j]);
int res = 0;
foreach (i, s) {
if (uf.Find(i->src) != uf.Find(i->dst)) {
uf.Union(i->src, i->dst);
res += i->weight;
e.push_back(*i);
}
}
return res;
}
int main() {
for (int n, m; cin >> n >> m, n;) {
Graph g(n);
rep(i, m) {
int src, dst, weight;
scanf("%d,%d,%d", &src, &dst, &weight);
g[src].push_back(Edge(src, dst, weight / 100 - 1));
g[dst].push_back(Edge(src, dst, weight / 100 - 1));
}
Edges e;
int sum = Kruskal(g, e);
// cout<<sum/100-e.size()<<endl;
cout << sum << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
#define dump(n) cout << "# " << #n << "=" << (n) << endl
#define debug(n) \
cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, n) repi(i, 0, n)
#define iter(c) __typeof((c).begin())
#define foreach(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define allof(c) (c).begin(), (c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
struct Edge {
int src, dst, weight;
Edge() {}
Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
bool operator<(const Edge &lhs, const Edge &rhs) {
return lhs.weight < rhs.weight;
}
bool operator>(const Edge &lhs, const Edge &rhs) {
return lhs.weight > rhs.weight;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
struct UnionFind {
vi data;
UnionFind(int size) : data(size, -1) {}
int Find(int n) { return data[n] < 0 ? n : (data[n] = Find(data[n])); }
void Union(int n1, int n2) {
int d1 = Find(n1);
int d2 = Find(n2);
if (d1 != d2) {
if (-data[d1] < -data[d2])
swap(d1, d2);
data[d1] += data[d2];
data[d2] = d1;
}
}
int Size(int n) { return -data[Find(n)]; }
};
int Kruskal(Graph &g, Edges &e) {
e.clear();
UnionFind uf(g.size());
multiset<Edge> s;
rep(i, g.size()) rep(j, g[i].size()) s.insert(g[i][j]);
int res = 0;
foreach (i, s) {
if (uf.Find(i->src) != uf.Find(i->dst)) {
uf.Union(i->src, i->dst);
res += i->weight;
e.push_back(*i);
}
}
return res;
}
// ostream& operator<<(ostream& os,const vi& a)
//{
// rep(i,a.size())
// printf("%d%s",a[i],i==a.size()-1?"":" ");
// return os;
//}
//
////pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
// pair<int, Edges> minimumSpanningForest(const Graph &g) {
// int n = g.size();
// UnionFind uf(n);
// //priority_queue<Edge> Q;
// priority_queue<Edge,vector<Edge>,greater<Edge> > Q;
// //rep(u, n) foreach(e, g[u]) if (u < e->dst) Q.push(*e);
// rep(u, n) foreach(e, g[u]) Q.push(*e);
// multiset<Edge> s;
// rep(i,g.size())rep(j,g[i].size())s.insert(g[i][j]);
// //puts("#s:");
// //foreach(i,s)
// // printf("%d %d %d\n",i->src,i->dst,i->weight);
//
// //Weight total = 0;
// int total = 0;
// Edges F;
// //while (F.size() < n-1 && !Q.empty()) {
// // Edge e = Q.top(); Q.pop();
// foreach(i,s){
// if(F.size()>=n)
// break;
// Edge e=*i;
// //if (uf.unionSet(e.src, e.dst)) {
// // F.push_back(e);
// // total += e.weight;
// //}
// if(uf.Find(e.src)!=uf.Find(e.dst)){
// uf.Union(e.src,e.dst);
// F.push_back(e);
// total+=e.weight;
// }
// }
// //puts("#F:");
// //rep(i,F.size())
// // printf("%d %d %d\n",F[i].src,F[i].dst,F[i].weight);
// //return pair<Weight, Edges>(total, F);
// return pair<int, Edges>(total, F);
//}
int main() {
for (int n, m; cin >> n >> m, n;) {
Graph g(n);
rep(i, m) {
int src, dst, weight;
scanf("%d,%d,%d", &src, &dst, &weight);
g[src].push_back(Edge(src, dst, weight / 100 - 1));
g[dst].push_back(Edge(src, dst, weight / 100 - 1));
}
Edges e;
int sum = Kruskal(g, e);
// cout<<sum/100-e.size()<<endl;
cout << sum << endl;
// cout<<minimumSpanningForest(g).first<<endl;
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78]]
| 1
| 673
| 2
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct Road {
int a, b;
int dist;
bool operator<(const Road &other) const { return dist < other.dist; }
};
int getroot(int i, vector<int> &roots) {
if (roots[i] == i)
return i;
return roots[i] = getroot(roots[i], roots);
}
void unite(int i, int j, vector<int> &roots) { roots[i] = getroot(j, roots); }
int main() {
while (true) {
int N, M;
cin >> N;
if (!N)
break;
cin >> M;
vector<Road> roads(M);
char comma;
for (int i = 0; i < M; ++i)
cin >> roads[i].a >> comma >> roads[i].b >> comma >> roads[i].dist;
sort(roads.begin(), roads.end());
int ans = 0;
vector<int> roots(N);
for (int i = 0; i < N; ++i)
roots[i] = i;
for (int i = 0; i < M; ++i) {
const Road &r = roads[i];
if (getroot(r.a, roots) == getroot(r.b, roots))
continue;
unite(r.a, r.b, roots);
ans += r.dist / 100 - 1;
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct Road {
int a, b;
int dist;
bool operator<(const Road &other) const { return dist < other.dist; }
};
int getroot(int i, vector<int> &roots) {
if (roots[i] == i)
return i;
return roots[i] = getroot(roots[i], roots);
}
void unite(int i, int j, vector<int> &roots) {
roots[getroot(i, roots)] = getroot(j, roots);
}
int main() {
while (true) {
int N, M;
cin >> N;
if (!N)
break;
cin >> M;
vector<Road> roads(M);
char comma;
for (int i = 0; i < M; ++i)
cin >> roads[i].a >> comma >> roads[i].b >> comma >> roads[i].dist;
sort(roads.begin(), roads.end());
int ans = 0;
vector<int> roots(N);
for (int i = 0; i < N; ++i)
roots[i] = i;
for (int i = 0; i < M; ++i) {
const Road &r = roads[i];
if (getroot(r.a, roots) == getroot(r.b, roots))
continue;
unite(r.a, r.b, roots);
ans += r.dist / 100 - 1;
}
cout << ans << endl;
}
return 0;
}
|
[["+", 0, 11, 31, 69, 341, 342, 0, 2, 63, 22], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 21], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 22], ["+", 31, 69, 341, 342, 0, 2, 3, 4, 0, 25]]
| 1
| 330
| 5
|
#include <iostream>
#include <stdio.h>
#include <vector>
#define INF 2147483647
using namespace std;
class Lantern {
public:
bool vector_find(vector<int> v, int key) {
for (int i = 0; i < v.size(); i++) {
if (v[i] == key) {
return 1;
}
}
return 0;
}
int Solve(int n, int roadlist[100][100]) {
int ans = 0, i, j;
vector<int> V;
V.push_back(0);
while (V.size() != n) {
int u, v, min = INF;
for (i = 0; i < V.size(); i++) {
for (j = 0; j < n; j++) {
if (!vector_find(V, j) && roadlist[i][j] < min) {
u = i, v = j;
min = roadlist[i][j];
}
}
}
ans += min;
V.push_back(v);
}
return ans;
}
};
int main() {
int n, m;
int rlist[100][100];
Lantern lantern;
while (1) {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
rlist[i][j] = INF;
}
}
scanf("%d", &n);
if (n == 0) {
break;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
int a, b, c;
scanf("%d,%d,%d", &a, &b, &c);
rlist[a][b] = rlist[b][a] = c / 100 - 1;
}
printf("%d\n", lantern.Solve(n, rlist));
}
}
|
#include <iostream>
#include <stdio.h>
#include <vector>
#define INF 2147483647
using namespace std;
class Lantern {
public:
bool vector_find(vector<int> v, int key) {
for (int i = 0; i < v.size(); i++) {
if (v[i] == key) {
return 1;
}
}
return 0;
}
int Solve(int n, int roadlist[100][100]) {
int ans = 0, i, j;
vector<int> V;
V.push_back(0);
while (V.size() != n) {
int u, v, min = INF;
for (i = 0; i < V.size(); i++) {
for (j = 0; j < n; j++) {
if (!vector_find(V, j) && roadlist[V[i]][j] < min) {
u = i, v = j;
min = roadlist[V[i]][j];
}
}
}
ans += min;
V.push_back(v);
}
return ans;
}
};
int main() {
int n, m;
int rlist[100][100];
Lantern lantern;
while (1) {
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
rlist[i][j] = INF;
}
}
scanf("%d", &n);
if (n == 0) {
break;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
int a, b, c;
scanf("%d,%d,%d", &a, &b, &c);
rlist[a][b] = rlist[b][a] = c / 100 - 1;
}
printf("%d\n", lantern.Solve(n, rlist));
}
}
|
[["+", 31, 69, 28, 69, 341, 342, 0, 69, 28, 22], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 0, 11, 12, 69, 28, 69, 341, 342, 0, 70], ["+", 12, 69, 28, 69, 341, 342, 0, 69, 28, 22]]
| 1
| 398
| 6
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define REP(i, n) for (i = 0; i < n; i++)
struct branch {
int n1, n2, w;
};
bool f(branch i, branch j) { return (i.w > j.w); }
int main() {
while (1) {
int n, i;
char c;
cin >> n;
if (n == 0)
break;
vector<int> T(n);
REP(i, n) T[i] = i;
branch tmp;
int m;
cin >> m;
vector<branch> S(m);
REP(i, m) cin >> S[i].n1 >> c >> S[i].n2 >> c >> S[i].w;
sort(S.begin(), S.end(), f);
int a = 0;
while (S.size()) {
tmp = S.back();
S.pop_back();
int b = T[tmp.n1], c = T[tmp.n2];
if (b != c) {
for (i = b + 1; i < n; i++)
if (T[i] == c)
T[i] = b;
a += tmp.w / 100 - 1;
}
}
cout << a << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define REP(i, n) for (i = 0; i < n; i++)
struct branch {
int n1, n2, w;
};
bool f(branch i, branch j) { return (i.w > j.w); }
int main() {
while (1) {
int n, i;
char c;
cin >> n;
if (n == 0)
break;
vector<int> T(n);
REP(i, n) T[i] = i;
branch tmp;
int m;
cin >> m;
vector<branch> S(m);
REP(i, m) cin >> S[i].n1 >> c >> S[i].n2 >> c >> S[i].w;
sort(S.begin(), S.end(), f);
int a = 0;
while (S.size()) {
tmp = S.back();
S.pop_back();
int b = T[tmp.n1], c = T[tmp.n2];
if (b != c) {
for (i = 0; i < n; i++)
if (T[i] == c)
T[i] = b;
a += tmp.w / 100 - 1;
}
}
cout << a << endl;
}
}
|
[["-", 64, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 7, 10, 11, 12, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 10, 11, 12, 13]]
| 1
| 286
| 42
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
double x = sc.nextDouble();
double h = sc.nextDouble();
if (x == 0 && h == 0) {
break;
}
System.out.printf("%.6f", Math.sqrt(h * h + x * x / 4) * x * 2 + x * x);
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
double x = sc.nextDouble();
double h = sc.nextDouble();
if (x == 0 && h == 0) {
break;
}
System.out.println(Math.sqrt(h * h + x * x / 4) * x * 2 + x * x);
}
}
}
|
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 21]]
| 3
| 107
| 6
|
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;
public class Main {
Scanner sc;
static final int INF = 1 << 28;
static final double EPS = 1e-9;
void run() {
sc = new Scanner(System.in);
for (; sc.hasNext();) {
int x = sc.nextInt();
int h = sc.nextInt();
if (x == 0 && h == 0)
break;
double l = sqrt(h * h + x * x / 4);
double s = x * x + 2 * x * l;
println(s + "");
}
sc.close();
}
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 static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;
public class Main {
Scanner sc;
static final int INF = 1 << 28;
static final double EPS = 1e-9;
void run() {
sc = new Scanner(System.in);
for (; sc.hasNext();) {
int x = sc.nextInt();
int h = sc.nextInt();
if (x == 0 && h == 0)
break;
double l = sqrt(h * h + x * x / 4.);
double s = x * x + 2 * x * l;
println(s + "");
}
sc.close();
}
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(); }
}
|
[["-", 51, 492, 3, 4, 0, 16, 12, 16, 12, 499], ["+", 51, 492, 3, 4, 0, 16, 12, 16, 12, 515]]
| 3
| 228
| 2
|
#include <math.h>
#include <stdio.h>
int main(void) {
int x[100], h[100];
double s[100];
int i = 0, j;
while (1) {
scanf("%d", &x[i]);
scanf("%d", &h[i]);
if (x[i] == 0 && h[i] == 0)
break;
s[i] = (4 * h[i] * h[i] + x[i] * x[i]);
s[i] = x[i] * sqrt(s[i]) + x[i] * x[i];
i++;
}
for (j = 0; j < i; j++) {
printf("%f\n", s[i]);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
int x[100], h[100];
double s[100];
int i = 0, j;
while (1) {
scanf("%d", &x[i]);
scanf("%d", &h[i]);
if (x[i] == 0 && h[i] == 0)
break;
s[i] = (4 * h[i] * h[i] + x[i] * x[i]);
s[i] = x[i] * sqrt(s[i]) + x[i] * x[i];
i++;
}
for (j = 0; j < i; j++) {
printf("%f\n", s[j]);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 71, 22]]
| 0
| 176
| 2
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x, h, S;
while (scanf("%d", &x) != EOF && scanf("%d", &h) != EOF) {
if (x == 0 && h == 0) {
break;
}
S = (x * x) + 4 * x * (sqrt(x * x / 4 + h * h) / 2);
printf("%f\n", S);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x, h, S;
while (scanf("%lf", &x) != EOF && scanf("%lf", &h) != EOF) {
if (x == 0 && h == 0) {
break;
}
S = (x * x) + 4 * x * sqrt(x * x / 4 + h * h) / 2;
printf("%f\n", S);
}
return 0;
}
|
[["-", 31, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 31, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 12, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 12, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 11, 12, 16, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 16, 12, 23, 0, 25]]
| 0
| 102
| 6
|
#include <math.h>
#include <stdio.h>
int input(int *x, int *h);
int main() {
int x, h;
double l, s;
while (input(&x, &h) == 0) {
l = sqrt((double)x * x / 4 + h * h);
s = l * x * 2 + x * x;
printf("%lf", s);
}
return 0;
}
int input(int *x, int *h) {
scanf("%d", x);
scanf("%d", h);
if (*x == 0 && *h == 0) {
return 1;
} else {
return 0;
}
}
|
#include <math.h>
#include <stdio.h>
int input(int *x, int *h);
int main() {
int x, h;
double l, s;
while (input(&x, &h) == 0) {
l = sqrt((double)x * x / 4 + h * h);
s = l * x * 2 + x * x;
printf("%lf\n", s);
}
return 0;
}
int input(int *x, int *h) {
scanf("%d", x);
scanf("%d", h);
if (*x == 0 && *h == 0) {
return 1;
} else {
return 0;
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 143
| 1
|
#include <math.h>
#include <stdio.h>
int main(void) {
int n, m;
double x, h, s, t;
while (1) {
scanf("%d %d", &n, &m);
if (n == 0 && m == 0)
break;
s = 0.0;
x = (double)n;
h = (double)m;
t = sqrt(pow(x / 2.0, 2) + pow(h, 2));
s = x * x + 4 * x * t / 2;
printf("%.6lf", s);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
int n, m;
double x, h, s, t;
while (1) {
scanf("%d %d", &n, &m);
if (n == 0 && m == 0)
break;
s = 0.0;
x = (double)n;
h = (double)m;
t = sqrt(pow(x / 2.0, 2) + pow(h, 2));
s = x * x + 4 * x * t / 2;
printf("%.6lf\n", s);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 121
| 1
|
#include <cstdio>
#include <math.h>
int main() {
int x, h;
double S;
for (;;) {
scanf("%d", &x);
scanf("%d", &h);
if (x == 0 && h == 0)
break;
double th = sqrt((x / 2 * x / 2) + (h * h));
S = x * x;
S += 4 * ((double)x * th / 2);
printf("%f\n", S);
}
return 0;
}
|
#include <cstdio>
#include <math.h>
int main() {
int x, h;
double S;
for (;;) {
scanf("%d", &x);
scanf("%d", &h);
if (x == 0 && h == 0)
break;
double th = sqrt(((double)x / 2 * (double)x / 2) + (h * h));
S = x * x;
S += 4 * ((double)x * th / 2);
printf("%f\n", S);
}
return 0;
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 24], ["+", 31, 16, 31, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 16, 31, 16, 31, 16, 31, 74, 0, 25], ["+", 31, 23, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 31, 23, 0, 16, 31, 16, 12, 74, 0, 25]]
| 1
| 113
| 6
|
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
int x, h;
double s;
while (1) {
cin >> x >> h;
if ((x == 0) && (h == 0))
break;
s = pow(x, 2.0) + x * sqrt(pow(h, 2.0) + pow(x, 2.0) / 4) * 2;
cout << setprecision(6) << s << endl;
}
return 0;
}
|
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
int x, h;
double s;
while (1) {
cin >> x >> h;
if ((x == 0) && (h == 0))
break;
s = pow(x, 2.0) + x * sqrt(pow(h, 2.0) + pow(x, 2.0) / 4) * 2;
cout << fixed << setprecision(6) << s << endl;
}
return 0;
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151]]
| 1
| 100
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
typedef long long int ll;
using namespace std;
int x, h;
double y;
double ans;
int main() {
while (1) {
cin >> x >> h;
if (x == 0 && h == 0)
break;
y = sqrt(4 * h * h + x * x) / 2.0;
ans = x * (2 * y + x);
printf("%.15lf", ans);
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
typedef long long int ll;
using namespace std;
int x, h;
double y;
double ans;
int main() {
while (1) {
cin >> x >> h;
if (x == 0 && h == 0)
break;
y = sqrt(4 * h * h + x * x) / 2.0;
ans = x * (2 * y + x);
printf("%.15lf\n", ans);
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 107
| 1
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double x, h;
while (1) {
scanf("%lf %lf", &x, &h);
if (x == 0 && h == 0)
break;
double soku =
sqrt(((double)x * 0.5) * ((double)x * 0.5) + (double)h * (double)h);
printf("%f", (double)x * (double)x + (double)4 * (soku * (double)x * 0.5));
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double x, h;
while (1) {
scanf("%lf %lf", &x, &h);
if (x == 0 && h == 0)
break;
double soku =
sqrt(((double)x * 0.5) * ((double)x * 0.5) + (double)h * (double)h);
printf("%f\n",
(double)x * (double)x + (double)4 * (soku * (double)x * 0.5));
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 115
| 1
|
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int size(string x) {
string::size_type size = x.size();
return size;
}
#define fu(l, k) for (int i = l; i < k; i++)
#define fd(l, k) for (int i = l; i > k; i--)
#define fi first
#define se second
typedef vector<string> vs;
typedef vector<int> vi;
double pi() { return M_PI; }
typedef set<int> set_i;
typedef set<string> set_s;
int INF = 1000000;
int main() {
int x, h;
double ssr, sr;
while (1) {
cin >> x;
cin >> h;
if (x == 0 && h == 0)
break;
sr = sqrt(h * h + x * x / 4);
ssr = 2 * x * sr + x * x;
printf("%.8lf\n", ssr);
}
}
|
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int size(string x) {
string::size_type size = x.size();
return size;
}
#define fu(l, k) for (int i = l; i < k; i++)
#define fd(l, k) for (int i = l; i > k; i--)
#define fi first
#define se second
typedef vector<string> vs;
typedef vector<int> vi;
double pi() { return M_PI; }
typedef set<int> set_i;
typedef set<string> set_s;
int INF = 1000000;
int main() {
int x, h;
double ssr, sr;
while (1) {
cin >> x;
cin >> h;
if (x == 0 && h == 0)
break;
sr = sqrt(h * h + (x * x) / 4.0);
ssr = sr * x * 2 + x * x;
printf("%.8lf\n", ssr);
}
}
|
[["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 25], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 12, 13], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 12, 13], ["-", 0, 11, 12, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13]]
| 1
| 189
| 8
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x, h, c;
while (1) {
scanf("%f %f", &x, &h);
if (x == 0.0 && h == 0.0)
break;
c = (x / 2.0) * (x / 2.0) + h * h;
c = sqrt(c);
c = x * x + x * c / 2.0 * 4.0;
printf("%f\n", c);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x, h, c;
while (1) {
scanf("%lf %lf", &x, &h);
if (x == 0.0 && h == 0.0)
break;
c = (x / 2.0) * (x / 2.0) + h * h;
c = sqrt(c);
c = x * x + x * c / 2.0 * 4.0;
printf("%lf\n", c);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 101
| 4
|
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double x, h, seihou = 0, naname = 0, y = 0, sannkaku = 0, kotae = 0;
while (true) {
cin >> x >> h;
if (x == 0 && h == 0) {
break;
}
seihou = x * x;
y = x / 2;
naname = sqrt(y * y + h * h);
sannkaku = x * naname * 4 / 2;
kotae = sannkaku + seihou;
printf("%.6f", kotae);
}
}
|
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double x, h, seihou = 0, naname = 0, y = 0, sannkaku = 0, kotae = 0;
while (true) {
cin >> x >> h;
if (x == 0 && h == 0) {
break;
}
seihou = x * x;
y = x / 2;
naname = sqrt(y * y + h * h);
sannkaku = x * naname * 4 / 2;
kotae = sannkaku + seihou;
printf("%.6f\n", kotae);
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 117
| 1
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 1000000;
int check(string str, char c) {
int ok[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6},
{1, 4, 8}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};
REP(i, 8) {
int cnt = 0;
REP(j, 3) if (str[ok[i][j]] == c)++ cnt;
if (cnt == 3)
return true;
}
return false;
}
int main() {
string str;
while (cin >> str) {
if (check(str, 'o'))
cout << 'o' << endl;
else if (check(str, 'x'))
cout << 'x' << endl;
else
cout << 'd' << endl;
}
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < j; i++)
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 1000000;
int check(string str, char c) {
int ok[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6},
{1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};
REP(i, 8) {
int cnt = 0;
REP(j, 3) if (str[ok[i][j]] == c)++ cnt;
if (cnt == 3)
return true;
}
return false;
}
int main() {
string str;
while (cin >> str) {
if (check(str, 'o'))
cout << 'o' << endl;
else if (check(str, 'x'))
cout << 'x' << endl;
else
cout << 'd' << endl;
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
| 1
| 272
| 2
|
#include <iostream>
#include <string>
int f(char a, char b, char c) {
return ((a != 's' && a == b && a == c) ? a : 0);
}
int main() {
std::string s;
int i, j;
while (getline(std::cin, s)) {
char c = (f(s[0], s[4], s[8]) || f(s[2], s[4], s[6])) ? s[4] : 0;
if (!c) {
for (i = 0; i < 3; i++) {
c = f(s[i], s[i + 3], s[i + 3]);
if (c)
break;
j = i * 3;
c = f(s[j], s[j + 1], s[j + 2]);
if (c)
break;
}
if (!c)
c = 'd';
}
std::cout << c << "\n";
}
}
|
#include <iostream>
#include <string>
int f(char a, char b, char c) {
return ((a != 's' && a == b && a == c) ? a : 0);
}
int main() {
std::string s;
int i, j;
while (getline(std::cin, s)) {
char c = (f(s[0], s[4], s[8]) || f(s[2], s[4], s[6])) ? s[4] : 0;
if (!c) {
for (i = 0; i < 3; i++) {
c = f(s[i], s[i + 3], s[i + 6]);
if (c)
break;
j = i * 3;
c = f(s[j], s[j + 1], s[j + 2]);
if (c)
break;
}
if (!c)
c = 'd';
}
std::cout << c << "\n";
}
}
|
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 227
| 2
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
class Main {
static int[][] map = new int[12][12];
static boolean[][] counted = new boolean[12][12];
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
continue;
for (int i = 0; i < 12; i++)
map[0][i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 1; i <= 11; i++) {
line = br.readLine();
for (int j = 0; j < 12; j++)
map[i][j] = Integer.parseInt(line.charAt(i) + "");
}
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
counted[i][j] = false;
int islanC = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] != 0 && !counted[i][j]) {
islanC++;
countIsl(i, j);
}
}
}
System.out.println(islanC);
}
} catch (Exception e) {
}
}
static void countIsl(int y, int x) {
if (counted[y][x])
return;
else {
counted[y][x] = true;
}
if (y != 0)
if (map[y - 1][x] != 0)
countIsl(y - 1, x);
if (y != 11)
if (map[y + 1][x] != 0)
countIsl(y + 1, x);
if (x != 11)
if (map[y][x + 1] != 0)
countIsl(y, x + 1);
if (x != 0)
if (map[y][x - 1] != 0)
countIsl(y, x - 1);
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
class Main {
static int[][] map = new int[12][12];
static boolean[][] counted = new boolean[12][12];
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.isEmpty())
continue;
for (int i = 0; i < 12; i++)
map[0][i] = Integer.parseInt(line.charAt(i) + "");
for (int i = 1; i <= 11; i++) {
line = br.readLine();
// System.out.println(line);
for (int j = 0; j < 12; j++)
map[i][j] = Integer.parseInt(line.charAt(j) + "");
}
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
counted[i][j] = false;
// for(int[] aa:map){System.out.println(Arrays.toString(aa));}
int islanC = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] != 0 && !counted[i][j]) {
// System.out.println("deli");
islanC++;
countIsl(i, j);
}
}
}
System.out.println(islanC);
}
} catch (Exception e) {
}
}
static void countIsl(int y, int x) {
if (counted[y][x])
return;
else { // System.out.println("MK x-y:"+x+"-"+y);
counted[y][x] = true;
}
if (y != 0)
if (map[y - 1][x] != 0)
countIsl(y - 1, x);
if (y != 11)
if (map[y + 1][x] != 0)
countIsl(y + 1, x);
if (x != 11)
if (map[y][x + 1] != 0)
countIsl(y, x + 1);
if (x != 0)
if (map[y][x - 1] != 0)
countIsl(y, x - 1);
}
}
|
[["-", 0, 493, 0, 454, 0, 522, 345, 522, 141, 22], ["+", 0, 493, 0, 454, 0, 522, 345, 522, 141, 22], ["-", 36, 36, 0, 493, 0, 454, 0, 522, 141, 22], ["+", 36, 36, 0, 493, 0, 454, 0, 522, 141, 22], ["-", 3, 4, 0, 16, 31, 492, 3, 4, 0, 22], ["+", 3, 4, 0, 16, 31, 492, 3, 4, 0, 22]]
| 3
| 493
| 6
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
StringBuilder builder = new StringBuilder();
Scanner scanner = new Scanner(System.in);
int n = 12;
int l = 12;
while (scanner.hasNext()) {
boolean[][] map = new boolean[l][n];
for (int i = 0; i < l; i++) {
String strs = scanner.nextLine();
for (int j = 0; j < n; j++) {
if (strs.charAt(j) == '1') {
map[i][j] = true;
}
}
}
int count = 0;
for (int i = 0; i < l; i++) {
for (int j = 0; j < n; j++) {
if (map[i][j]) {
count++;
dfs(i, j, map, n, l);
}
}
}
System.out.println(count);
if (scanner.nextLine().isEmpty()) {
continue;
}
}
}
private static void dfs(int y, int x, boolean[][] map, int n, int l) {
int[] dx = {-1, 0, 0, 1};
int[] dy = {0, 1, -1, 0};
Deque<int[]> deque = new ArrayDeque<int[]>();
deque.push(new int[] {y, x});
while (!deque.isEmpty()) {
int[] a = deque.pop();
int ny = a[0];
int nx = a[1];
map[ny][nx] = false;
for (int i = 0; i < 4; i++) {
int py = ny + dy[i];
int px = nx + dx[i];
if (0 <= px && px < n && 0 <= py && py < l && map[py][px]) {
deque.push(new int[] {py, px});
}
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
StringBuilder builder = new StringBuilder();
Scanner scanner = new Scanner(System.in);
int n = 12;
int l = 12;
while (scanner.hasNext()) {
boolean[][] map = new boolean[l][n];
for (int i = 0; i < l; i++) {
String strs = scanner.next();
for (int j = 0; j < n; j++) {
if (strs.charAt(j) == '1') {
map[i][j] = true;
}
}
}
int count = 0;
for (int i = 0; i < l; i++) {
for (int j = 0; j < n; j++) {
if (map[i][j]) {
count++;
dfs(i, j, map, n, l);
}
}
}
System.out.println(count);
if (scanner.nextLine().isEmpty()) {
continue;
}
}
}
private static void dfs(int y, int x, boolean[][] map, int n, int l) {
int[] dx = {-1, 0, 0, 1};
int[] dy = {0, 1, -1, 0};
Deque<int[]> deque = new ArrayDeque<int[]>();
deque.push(new int[] {y, x});
while (!deque.isEmpty()) {
int[] a = deque.pop();
int ny = a[0];
int nx = a[1];
map[ny][nx] = false;
for (int i = 0; i < 4; i++) {
int py = ny + dy[i];
int px = nx + dx[i];
if (0 <= px && px < n && 0 <= py && py < l && map[py][px]) {
deque.push(new int[] {py, px});
}
}
}
}
}
|
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
| 3
| 505
| 2
|
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
static boolean[][] judge;
static int[] fieldX = {-1, 0, 1, 0}, fieldY = {0, -1, 0, 1};
static void doing(int x, int y) {
judge[y][x] = false;
for (int i = 0; i < 4; i++) {
if (judge[y + fieldY[i]][x + fieldX[i]])
doing(x + fieldX[i], y + fieldY[i]);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNext()) {
judge = new boolean[20][20];
for (int i = 1; i <= 12; i++) {
String temp = sc.next();
for (int x = 1; x <= 12; x++) {
judge[i][x] = temp.charAt(x - 1) == '1';
}
}
int count = 0;
for (int i = 1; i <= 12; i++) {
for (int x = 1; x <= 12; x++) {
if (judge[i][x])
count++;
doing(x, i);
}
}
out.println(count);
}
out.flush();
}
}
|
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
static boolean[][] judge;
static int[] fieldX = {-1, 0, 1, 0}, fieldY = {0, -1, 0, 1};
static void doing(int x, int y) {
judge[y][x] = false;
for (int i = 0; i < 4; i++) {
if (judge[y + fieldY[i]][x + fieldX[i]])
doing(x + fieldX[i], y + fieldY[i]);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNext()) {
judge = new boolean[20][20];
for (int i = 1; i <= 12; i++) {
String temp = sc.next();
for (int x = 1; x <= 12; x++) {
judge[i][x] = temp.charAt(x - 1) == '1';
}
}
int cnt = 0;
for (int i = 1; i <= 12; i++) {
for (int x = 1; x <= 12; x++) {
if (judge[i][x]) {
cnt++;
doing(x, i);
}
}
}
out.println(cnt);
}
out.flush();
}
}
|
[["-", 0, 52, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 0, 52, 8, 196, 0, 503, 49, 200, 141, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 27, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 22], ["+", 0, 52, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22]]
| 3
| 317
| 8
|
import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
static boolean[][] map;
static boolean[][] check;
static int island;
public static void main(String[] args) {
while (true) {
map = new boolean[12][12];
check = new boolean[12][12];
island = 0;
for (int i = 0; i < 12; i++) {
int count = 0;
for (String s : scan.nextLine().split("", 0)) {
if (s.equals("1")) {
map[i][count] = true;
} else {
map[i][count] = false;
}
count++;
}
}
for (int i = 0; i < 12; i++) {
for (int u = 0; u < 12; u++) {
if (map[i][u] && !check[i][u]) {
fun(i, u);
}
}
}
System.out.println(island);
}
}
static void fun(int x, int y) {
flag(x, y);
island++;
}
static void flag(int x, int y) {
check[x][y] = true;
if (y + 1 < 12 && map[x][y + 1] && !check[x][y + 1]) {
flag(x, y + 1);
}
if (x + 1 < 12 && map[x + 1][y] && !check[x + 1][y]) {
flag(x + 1, y);
}
if (y - 1 > -1 && map[x][y - 1] && !check[x][y - 1]) {
flag(x, y - 1);
}
if (x - 1 > -1 && map[x - 1][y] && !check[x - 1][y]) {
flag(x - 1, y);
}
}
}
|
import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
static boolean[][] map;
static boolean[][] check;
static int island;
public static void main(String[] args) {
while (scan.hasNext()) {
map = new boolean[12][12];
check = new boolean[12][12];
island = 0;
for (int i = 0; i < 12; i++) {
int count = 0;
for (String s : scan.next().split("", 0)) {
if (s.equals("1")) {
map[i][count] = true;
} else {
map[i][count] = false;
}
count++;
}
}
for (int i = 0; i < 12; i++) {
for (int u = 0; u < 12; u++) {
if (map[i][u] && !check[i][u]) {
fun(i, u);
}
}
}
System.out.println(island);
}
}
static void fun(int x, int y) {
flag(x, y);
island++;
}
static void flag(int x, int y) {
check[x][y] = true;
if (y + 1 < 12 && map[x][y + 1] && !check[x][y + 1]) {
flag(x, y + 1);
}
if (x + 1 < 12 && map[x + 1][y] && !check[x + 1][y]) {
flag(x + 1, y);
}
if (y - 1 > -1 && map[x][y - 1] && !check[x][y - 1]) {
flag(x, y - 1);
}
if (x - 1 > -1 && map[x - 1][y] && !check[x - 1][y]) {
flag(x - 1, y);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 15, 0, 146], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 500, 22], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 0, 131], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["+", 0, 52, 15, 15, 0, 492, 3, 4, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 15, 0, 25], ["-", 8, 196, 0, 514, 51, 492, 500, 492, 141, 22], ["+", 8, 196, 0, 514, 51, 492, 500, 492, 141, 22]]
| 3
| 444
| 8
|
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[][] land = new int[12][12];
int count = 0;
ArrayList<Integer> islandCount = new ArrayList<>();
while (in.hasNext()) {
for (int i = 0; i < 12; i++) {
String a = in.next();
for (int j = 0; j < 12; j++) {
char b = a.charAt(j);
int c = Integer.parseInt(b + "");
land[i][j] = c;
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (land[i][j] == 1) {
island(land, i, j);
count++;
}
}
}
System.out.println(count);
}
}
private static void island(int[][] land, int i, int j) {
if (land[i][j] == 1) {
land[i][j] = 0;
if (i > 0) {
island(land, i - 1, j);
}
if (i < 11) {
island(land, i + 1, j);
}
if (j > 0) {
island(land, i, j - 1);
}
if (j < 11) {
island(land, i, j + 1);
}
} else {
return;
}
/*
* if(land[i + 1][j] == 0 && land[i - 1][j] == 0 && land[i][j + 1] == 0 &&
* land[i][j - 1] == 0) {
*
* land[i][j] = 0;
*
* } else if(land[i + 1][j] == 1 || land[i - 1][j] != 0 || land[i][j + 1] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i + 1, j);
*
* } else if(land[j + 1][j] == 1 && land[i + 1][j] == 0 || land[i - 1][j] !=
* 0
* || land[i][j - 1] != 0) {
*
* island(land, i, j + 1);
*
* } else if(land[i][j - 1] == 1 && land[i + 1][j] == 0 || land[i - 1][j] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i, j - 1);
*
* } else if(land[i][i - 1] == 1 && land[i + 1][j] == 0 || land[i][j + 1] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i - 1, j);
*
* }
*
* land[i][j] = 0;
*/
}
}
|
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[][] land = new int[12][12];
int count = 0;
ArrayList<Integer> islandCount = new ArrayList<>();
while (in.hasNext()) {
for (int i = 0; i < 12; i++) {
String a = in.next();
for (int j = 0; j < 12; j++) {
char b = a.charAt(j);
int c = Integer.parseInt(b + "");
land[i][j] = c;
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (land[i][j] == 1) {
island(land, i, j);
count++;
}
}
}
System.out.println(count);
count = 0;
}
}
private static void island(int[][] land, int i, int j) {
if (land[i][j] == 1) {
land[i][j] = 0;
if (i > 0) {
island(land, i - 1, j);
}
if (i < 11) {
island(land, i + 1, j);
}
if (j > 0) {
island(land, i, j - 1);
}
if (j < 11) {
island(land, i, j + 1);
}
} else {
return;
}
/*
* if(land[i + 1][j] == 0 && land[i - 1][j] == 0 && land[i][j + 1] == 0 &&
* land[i][j - 1] == 0) {
*
* land[i][j] = 0;
*
* } else if(land[i + 1][j] == 1 || land[i - 1][j] != 0 || land[i][j + 1] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i + 1, j);
*
* } else if(land[j + 1][j] == 1 && land[i + 1][j] == 0 || land[i - 1][j] !=
* 0
* || land[i][j - 1] != 0) {
*
* island(land, i, j + 1);
*
* } else if(land[i][j - 1] == 1 && land[i + 1][j] == 0 || land[i - 1][j] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i, j - 1);
*
* } else if(land[i][i - 1] == 1 && land[i + 1][j] == 0 || land[i][j + 1] !=
* 0
* || land[i][j - 1] != 0){
*
* island(land, i - 1, j);
*
* }
*
* land[i][j] = 0;
*/
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 3
| 353
| 4
|
import java.util.Scanner;
class Main {
static Scanner sc;
static boolean ISCHK[][];
static int num, STATE[][];
public static void main(String[] args) {
sc = new Scanner(System.in);
ISCHK = new boolean[14][14];
STATE = new int[14][14];
String tmpstr = new String("");
while (sc.hasNext()) {
num = 0;
for (int i = 0; i < 14; i++) {
if (i > 0 && i < 13) {
tmpstr = sc.next();
}
for (int j = 0; j < 14; j++) {
if (i > 0 && i < 13) {
if (j == 0 || j == 13) {
STATE[i][j] = 0;
ISCHK[i][j] = true;
} else if (j < 13) {
ISCHK[i][j + 1] = false;
STATE[i][j] = Integer.parseInt(tmpstr.substring(j - 1, j));
}
} else {
STATE[i][j] = 0;
ISCHK[i][j] = true;
}
}
}
for (int i = 1; i < 13; i++) {
for (int j = 1; j < 13; j++) {
if (ISCHK[i][j] == false) {
if (STATE[i][j] == 0) {
ISCHK[i][j] = true;
} else {
ISCHK[i][j] = true;
num++;
srch(i, j);
}
}
}
}
System.out.println(num);
}
}
static void srch(int nowX, int nowY) {
if (ISCHK[nowX - 1][nowY] == false && STATE[nowX - 1][nowY] == 1) {
ISCHK[nowX - 1][nowY] = true;
srch(nowX - 1, nowY);
}
if (ISCHK[nowX][nowY - 1] == false && STATE[nowX][nowY - 1] == 1) {
ISCHK[nowX][nowY - 1] = true;
srch(nowX, nowY - 1);
}
if (ISCHK[nowX + 1][nowY] == false && STATE[nowX + 1][nowY] == 1) {
ISCHK[nowX + 1][nowY] = true;
srch(nowX + 1, nowY);
}
if (ISCHK[nowX][nowY + 1] == false && STATE[nowX][nowY + 1] == 1) {
ISCHK[nowX][nowY + 1] = true;
srch(nowX, nowY + 1);
}
}
}
|
import java.util.Scanner;
class Main {
static Scanner sc;
static boolean ISCHK[][];
static int num, STATE[][];
public static void main(String[] args) {
sc = new Scanner(System.in);
ISCHK = new boolean[14][14];
STATE = new int[14][14];
String tmpstr = new String("");
while (sc.hasNext()) {
num = 0;
for (int i = 0; i < 14; i++) {
if (i > 0 && i < 13) {
tmpstr = sc.next();
}
for (int j = 0; j < 14; j++) {
if (i > 0 && i < 13) {
if (j == 0 || j == 13) {
STATE[i][j] = 0;
ISCHK[i][j] = true;
} else if (j < 13) {
ISCHK[i][j] = false;
STATE[i][j] = Integer.parseInt(tmpstr.substring(j - 1, j));
}
} else {
STATE[i][j] = 0;
ISCHK[i][j] = true;
}
}
}
for (int i = 1; i < 13; i++) {
for (int j = 1; j < 13; j++) {
if (ISCHK[i][j] == false) {
if (STATE[i][j] == 0) {
ISCHK[i][j] = true;
} else {
ISCHK[i][j] = true;
num++;
srch(i, j);
}
}
}
}
System.out.println(num);
}
}
static void srch(int nowX, int nowY) {
if (ISCHK[nowX - 1][nowY] == false && STATE[nowX - 1][nowY] == 1) {
ISCHK[nowX - 1][nowY] = true;
srch(nowX - 1, nowY);
}
if (ISCHK[nowX][nowY - 1] == false && STATE[nowX][nowY - 1] == 1) {
ISCHK[nowX][nowY - 1] = true;
srch(nowX, nowY - 1);
}
if (ISCHK[nowX + 1][nowY] == false && STATE[nowX + 1][nowY] == 1) {
ISCHK[nowX + 1][nowY] = true;
srch(nowX + 1, nowY);
}
if (ISCHK[nowX][nowY + 1] == false && STATE[nowX][nowY + 1] == 1) {
ISCHK[nowX][nowY + 1] = true;
srch(nowX, nowY + 1);
}
}
}
|
[["-", 0, 1, 0, 11, 31, 504, 71, 16, 17, 72], ["-", 0, 1, 0, 11, 31, 504, 71, 16, 12, 499]]
| 3
| 575
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) { new Main().run(); }
char[][] map;
public void run() {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String str = scan.nextLine();
if (str.equals(" ")) {
continue;
}
map = new char[12][];
map[0] = str.toCharArray();
for (int i = 1; i < 12; i++) {
map[i] = scan.nextLine().toCharArray();
}
int count = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] == '1') {
count++;
checkMap(i, j);
}
}
}
System.out.println(count);
}
}
public void checkMap(int i, int j) {
if (map[i][j] == '0') {
return;
}
map[i][j] = '0';
int[] dx = {-1, 1, 0, 0};
int[] dy = {0, 0, -1, 1};
for (int k = 0; k < 4; k++) {
if (i + dy[k] >= 0 && i + dy[k] < 12 && j + dx[k] >= 0 &&
j + dx[k] < 12) {
checkMap(i + dy[k], j + dx[k]);
}
}
return;
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) { new Main().run(); }
char[][] map;
public void run() {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String str = scan.nextLine();
if (str.equals("")) {
continue;
}
map = new char[12][];
map[0] = str.toCharArray();
for (int i = 1; i < 12; i++) {
map[i] = scan.nextLine().toCharArray();
}
int count = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] == '1') {
count++;
checkMap(i, j);
}
}
}
System.out.println(count);
}
}
public void checkMap(int i, int j) {
if (map[i][j] == '0') {
return;
}
map[i][j] = '0';
int[] dx = {-1, 1, 0, 0};
int[] dy = {0, 0, -1, 1};
for (int k = 0; k < 4; k++) {
if (i + dy[k] >= 0 && i + dy[k] < 12 && j + dx[k] >= 0 &&
j + dx[k] < 12) {
checkMap(i + dy[k], j + dx[k]);
}
}
return;
}
}
|
[["-", 15, 15, 0, 492, 3, 4, 0, 5, 0, 491]]
| 3
| 359
| 1
|
#include <stdio.h>
char a[13][13];
int count;
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
void lake(int i, int j) {
int newx, newy;
int k;
a[i][j] = '0';
// if (a[i][j] == '1'){
for (k = 0; k < 4; k++) {
newx = i + dx[k];
newy = j + dy[k];
if (newx >= 0 && newy >= 0 && newx < 12 && newy < 12 &&
a[newx][newy] == '1') {
lake(newx, newy);
}
}
// }
}
int main(void) {
int i, j;
while (1) {
for (i = 0; i < 12; i++) {
if (scanf("%s", a[i]) == EOF) {
return (0);
}
}
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++) {
if (a[i][j] == '1') {
lake(i, j);
count++;
}
}
}
printf("count = %d\n", count);
count = 0;
}
}
|
#include <stdio.h>
char a[13][13];
int count;
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
void lake(int i, int j) {
int newx, newy;
int k;
a[i][j] = '0';
// if (a[i][j] == '1'){
for (k = 0; k < 4; k++) {
newx = i + dx[k];
newy = j + dy[k];
if (newx >= 0 && newy >= 0 && newx < 12 && newy < 12 &&
a[newx][newy] == '1') {
lake(newx, newy);
}
}
// }
}
int main(void) {
int i, j;
while (1) {
for (i = 0; i < 12; i++) {
if (scanf("%s", a[i]) == EOF) {
return (0);
}
}
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++) {
if (a[i][j] == '1') {
lake(i, j);
count++;
}
}
}
printf("%d\n", count);
count = 0;
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 275
| 2
|
#include <iostream>
#include <math.h>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int map[12][12];
void SagasiteHappy(int i, int j) {
map[i][j] = 0;
if (i >= 0) {
if (map[i - 1][j] == 1) {
SagasiteHappy(i - 1, j);
}
}
if (i < 12) {
if (map[i + 1][j] == 1) {
SagasiteHappy(i + 1, j);
}
}
if (j >= 0) {
if (map[i][j - 1] == 1) {
SagasiteHappy(i, j - 1);
}
}
if (j < 12) {
if (map[i][j + 1] == 1) {
SagasiteHappy(i, j + 1);
}
}
}
int main() {
string line;
while (cin >> line) {
int cnt = 0;
for (int i = 0; i < 12; i++) {
map[0][i] = line[i] - '0';
}
for (int i = 1; i < 12; i++) {
cin >> line;
for (int j = 0; j < 12; j++) {
map[i][j] = line[j] - '0';
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] == 1) {
cnt++;
SagasiteHappy(
i,
j); //まずijを0にして、上下左右探して1ならそいつをSagasiteHappyする
}
}
}
cout << cnt << endl;
}
return 0;
}
|
#include <iostream>
#include <math.h>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int map[12][12];
void SagasiteHappy(int i, int j) {
map[i][j] = 0;
if (i > 0) {
if (map[i - 1][j] == 1) {
SagasiteHappy(i - 1, j);
}
}
if (i < 11) {
if (map[i + 1][j] == 1) {
SagasiteHappy(i + 1, j);
}
}
if (j > 0) {
if (map[i][j - 1] == 1) {
SagasiteHappy(i, j - 1);
}
}
if (j < 11) {
if (map[i][j + 1] == 1) {
SagasiteHappy(i, j + 1);
}
}
}
int main() {
string line;
while (cin >> line) {
int cnt = 0;
for (int i = 0; i < 12; i++) {
map[0][i] = line[i] - '0';
}
for (int i = 1; i < 12; i++) {
cin >> line;
for (int j = 0; j < 12; j++) {
map[i][j] = line[j] - '0';
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (map[i][j] == 1) {
cnt++;
SagasiteHappy(
i,
j); //まずijを0にして、上下左右探して1ならそいつをSagasiteHappyする
}
}
}
cout << cnt << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 350
| 8
|
#include <cstdio>
char field[12][12];
void rec(int i, int j) {
field[i][j] = '0';
if (field[i + 1][j] == '1' && i + 1 < 12)
rec(i + 1, j);
if (field[i - 1][j] == '1' && i - 1 > -1)
rec(i - 1, j);
if (field[i][j + 1] == '1' && j + 1 < 12)
rec(i, j + 1);
if (field[i][j - 1] == '1' && j - 1 > -1)
rec(i, j - 1);
}
int main() {
int count = 0;
while (1) {
bool end = false;
for (int i = 0; i < 12; i++) {
if (scanf("%s", &field[i]) == EOF)
end = true;
}
if (end)
break;
count = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (field[i][j] == '1') {
rec(i, j);
count++;
}
}
}
printf("%d\n", count);
putchar('\n');
}
return 0;
}
|
#include <cstdio>
char field[12][12];
void rec(int i, int j) {
field[i][j] = '0';
if (field[i + 1][j] == '1' && i + 1 < 12)
rec(i + 1, j);
if (field[i - 1][j] == '1' && i - 1 > -1)
rec(i - 1, j);
if (field[i][j + 1] == '1' && j + 1 < 12)
rec(i, j + 1);
if (field[i][j - 1] == '1' && j - 1 > -1)
rec(i, j - 1);
}
int main() {
int count = 0;
while (1) {
bool end = false;
for (int i = 0; i < 12; i++) {
if (scanf("%s", &field[i]) == EOF)
end = true;
}
if (end)
break;
count = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (field[i][j] == '1') {
rec(i, j);
count++;
}
}
}
printf("%d\n", count);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 103, 0, 104], ["-", 0, 1, 0, 2, 3, 4, 0, 103, 0, 44], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 305
| 7
|
#include <cstdio>
int sima(int x, int y);
char SIMA[14][14];
int main() {
while (scanf("%s", SIMA[1]) != EOF) {
int i, j, ans = 0;
for (i = 2; i < 13; i++) {
scanf("%s", SIMA[i] + 1);
}
for (i = 1; i < 13; i++) {
for (j = 1; j < 13; j++) {
if (SIMA[j][i] == '1') {
ans += sima(j, i);
}
}
}
printf("%d\n", ans);
}
return 0;
}
int sima(int x, int y) {
if (SIMA[x][y] == '0' || SIMA[x][y] == 0)
return 1;
else
SIMA[x][y] = '0';
return sima(x + 1, y) * sima(x, y + 1) * sima(x - 1, y) * sima(x, y - 1);
}
|
#include <cstdio>
int sima(int x, int y);
char SIMA[14][14];
int main() {
while (scanf("%s", SIMA[1] + 1) != EOF) {
int i, j, ans = 0;
for (i = 2; i < 13; i++) {
scanf("%s", SIMA[i] + 1);
}
for (i = 1; i < 13; i++) {
for (j = 1; j < 13; j++) {
if (SIMA[j][i] == '1') {
ans += sima(j, i);
}
}
}
printf("%d\n", ans);
}
return 0;
}
int sima(int x, int y) {
if (SIMA[x][y] == '0' || SIMA[x][y] == 0)
return 1;
else
SIMA[x][y] = '0';
return sima(x + 1, y) * sima(x, y + 1) * sima(x - 1, y) * sima(x, y - 1);
}
|
[["+", 51, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 239
| 17
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char shima[13][13];
void tansaku(int x, int y) {
if (x < 0 || x > 11 || y < 0 || y > 11 || shima[y][x] == '0')
return;
if (shima[y][x] == '1') {
shima[y][x] = '0';
}
tansaku(x + 1, y);
tansaku(x - 1, y);
tansaku(x, y + 1);
tansaku(x, y - 1);
}
int main() {
while (cin >> shima[0][0]) {
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (i != 0 && j != 0)
cin >> shima[i][j];
}
}
int a = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (shima[i][j] == '1') {
tansaku(j, i);
a++;
}
}
}
cout << a << endl;
}
}
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char shima[13][13];
void tansaku(int x, int y) {
if (x < 0 || x > 11 || y < 0 || y > 11 || shima[y][x] == '0')
return;
if (shima[y][x] == '1') {
shima[y][x] = '0';
}
tansaku(x + 1, y);
tansaku(x - 1, y);
tansaku(x, y + 1);
tansaku(x, y - 1);
}
int main() {
while (cin >> shima[0][0]) {
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (i == 0 && j == 0)
continue;
else
cin >> shima[i][j];
}
}
int a = 0;
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (shima[i][j] == '1') {
tansaku(j, i);
a++;
}
}
}
cout << a << endl;
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 35], ["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
| 1
| 289
| 7
|
#include <algorithm>
#include <cstdio>
using namespace std;
int masu[14][14];
int cont;
void saiki(int x, int y) {
masu[x][y] = 0;
if (masu[x + 1][y] == 1) {
saiki(x + 1, y);
}
if (masu[x - 1][y] == 1) {
saiki(x - 1, y);
}
if (masu[x][y + 1] == 1) {
saiki(x, y + 1);
}
if (masu[x][y - 1] == 1) {
saiki(x, y - 1);
}
}
int main() {
while (1) {
for (int i = 0; i < 14; i++) {
for (int j = 0; j < 14; j++)
masu[i][j] = 0;
}
cont = 0;
char str[100];
for (int i = 1; i <= 12; i++) {
if (scanf("%s", str) == EOF) {
goto A;
}
for (int j = 1; j <= 12; j++) {
if (str[j] == '1') {
masu[i][j] = 1;
}
}
}
for (int i = 1; i <= 12; i++) {
for (int j = 1; j <= 12; j++) {
if (masu[i][j] == 1) {
saiki(i, j);
cont++;
}
}
}
printf("%d\n", cont);
}
A:;
}
|
#include <algorithm>
#include <cstdio>
using namespace std;
int masu[14][14];
int cont;
void saiki(int x, int y) {
masu[x][y] = 0;
if (masu[x + 1][y] == 1) {
saiki(x + 1, y);
}
if (masu[x - 1][y] == 1) {
saiki(x - 1, y);
}
if (masu[x][y + 1] == 1) {
saiki(x, y + 1);
}
if (masu[x][y - 1] == 1) {
saiki(x, y - 1);
}
}
int main() {
while (1) {
for (int i = 0; i < 14; i++) {
for (int j = 0; j < 14; j++)
masu[i][j] = 0;
}
cont = 0;
char str[100];
for (int i = 1; i <= 12; i++) {
if (scanf("%s", str) == EOF) {
goto A;
}
for (int j = 1; j <= 12; j++) {
if (str[j - 1] == '1') {
masu[i][j] = 1;
}
}
}
for (int i = 1; i <= 12; i++) {
for (int j = 1; j <= 12; j++) {
if (masu[i][j] == 1) {
saiki(i, j);
cont++;
}
}
}
printf("%d\n", cont);
}
A:;
}
|
[["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 345
| 2
|
// 0067
#include <stdio.h>
const int N = 12;
const int P = 4;
char a[N + P][N + P];
void Sink(int x, int y) {
if (a[x][y] == '1') {
a[x][y] = '0';
Sink(x + 1, y);
Sink(x - 1, y);
Sink(x, y + 1);
Sink(x, y - 1);
}
}
int main(void) {
int i, j;
int count = 0;
for (;;) {
count = 0;
for (i = 0; i < N; i++) {
if (!fgets(a[i + 1], N + 2, stdin)) {
return 0;
}
if (a[i + 1][0] == '\n')
i--;
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (a[i + 1][j + 1] == '1') {
Sink(i + 1, j + 1);
count++;
}
}
}
printf("%d\n", count);
}
return 1;
}
|
// 0067
#include <stdio.h>
const int N = 12;
const int P = 4;
char a[N + P][N + P];
void Sink(int x, int y) {
if (a[x][y] == '1') {
a[x][y] = '0';
Sink(x + 1, y);
Sink(x - 1, y);
Sink(x, y + 1);
Sink(x, y - 1);
}
}
int main(void) {
int i, j;
int count = 0;
for (;;) {
count = 0;
for (i = 0; i < N; i++) {
if (!fgets(a[i + 1] + 1, N + 2, stdin)) {
return 0;
}
if (a[i + 1][1] == '\n')
i--;
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (a[i + 1][j + 1] == '1') {
Sink(i + 1, j + 1);
count++;
}
}
}
printf("%d\n", count);
}
return 1;
}
/*
101111111101
001111111100
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
001111111100
101111111101
*/
|
[["+", 51, 91, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 91, 28, 2, 3, 4, 0, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13]]
| 1
| 266
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
char a[12][12];
void irand(int i, int j) {
a[i][j] == '0';
if (i > 0 && a[i - 1][j] == '1')
irand(i - 1, j);
if (j > 0 && a[i][j - 1] == '1')
irand(i, j - 1);
if (i < 11 && a[i + 1][j] == '1')
irand(i + 1, j);
if (j < 11 && a[i][j + 1] == '1')
irand(i, j + 1);
return;
}
int main() {
while (scanf("%s", a[0]) != EOF) {
int cnt = 0;
for (int i = 1; i < 12; i++)
scanf("%s", a[i]);
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (a[i][j] == '1') {
cnt++;
irand(i, j);
}
}
}
printf("%d\n", cnt);
}
}
|
#include <cstdio>
#include <iostream>
using namespace std;
char a[12][12];
void irand(int i, int j) {
a[i][j] = '0';
if (i > 0 && a[i - 1][j] == '1')
irand(i - 1, j);
if (j > 0 && a[i][j - 1] == '1')
irand(i, j - 1);
if (i < 11 && a[i + 1][j] == '1')
irand(i + 1, j);
if (j < 11 && a[i][j + 1] == '1')
irand(i, j + 1);
return;
}
int main() {
while (scanf("%s", a[0]) != EOF) {
int cnt = 0;
for (int i = 1; i < 12; i++)
scanf("%s", a[i]);
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (a[i][j] == '1') {
cnt++;
irand(i, j);
}
}
}
printf("%d\n", cnt);
}
}
|
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32]]
| 1
| 281
| 2
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
string str;
int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
bool m[10][10];
void dfs(int x, int y) {
for (int i = 0; i < 4; i++) {
int tx = x + xs[i], ty = y + ys[i];
if (tx < 0 || tx >= 12 || ty < 0 || ty >= 12)
continue;
if (m[tx][ty]) {
m[tx][ty] = false;
dfs(tx, ty);
}
}
}
int main() {
while (true) {
int res = 0;
for (int i = 0; i < 12; i++) {
if (cin >> str) {
for (int j = 0; j < str.size(); j++) {
m[i][j] = str[j] == '1';
}
} else
return 0;
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (m[i][j]) {
res++;
dfs(i, j);
}
}
}
cout << res << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
string str;
int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
bool m[20][20];
void dfs(int x, int y) {
for (int i = 0; i < 4; i++) {
int tx = x + xs[i], ty = y + ys[i];
if (tx < 0 || tx >= 12 || ty < 0 || ty >= 12)
continue;
if (m[tx][ty]) {
m[tx][ty] = false;
dfs(tx, ty);
}
}
}
int main() {
while (true) {
int res = 0;
for (int i = 0; i < 12; i++) {
if (cin >> str) {
for (int j = 0; j < str.size(); j++) {
m[i][j] = str[j] == '1';
}
} else
return 0;
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
if (m[i][j]) {
res++;
dfs(i, j);
}
}
}
cout << res << endl;
}
}
|
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
| 1
| 288
| 4
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
void island(vcs &board, int i, int j) {
if (i < 0 || i >= 12 || j < 0 || j >= 12)
return;
if (board[i][j] == '0')
return;
board[i][j] = '0';
island(board, i + 1, j);
island(board, i, j + 1);
island(board, i - 1, j);
island(board, i, j - 1);
}
int main() {
string s;
vcs board(12);
while (cin >> s) {
board[0] = s;
for_(i, 1, 12) {
cin >> s;
board[i] = s;
}
int ans = 0;
for_(i, 0, 12) for_(j, 0, 12) {
if (board[i][j] == '1') {
ans++;
island(board, i, j);
}
}
cout << ans << endl;
cin >> s;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
void island(vcs &board, int i, int j) {
if (i < 0 || i >= 12 || j < 0 || j >= 12)
return;
if (board[i][j] == '0')
return;
board[i][j] = '0';
island(board, i + 1, j);
island(board, i, j + 1);
island(board, i - 1, j);
island(board, i, j - 1);
}
int main() {
string s;
vcs board(12);
while (cin >> s) {
board[0] = s;
for_(i, 1, 12) {
cin >> s;
board[i] = s;
}
int ans = 0;
for_(i, 0, 12) for_(j, 0, 12) {
if (board[i][j] == '1') {
ans++;
island(board, i, j);
}
}
cout << ans << endl;
getline(cin, s);
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
| 1
| 390
| 5
|
#include <array>
#include <iostream>
using namespace std;
array<array<char, 12>, 12> maap;
void dfs(int x, int y) {
maap[x][y] = '0';
int dx[] = {0, -1, 1, 0}, dy[] = {1, 0, 0, -1};
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 0 && nx < 12 && ny >= 0 && nx < 12 && maap[nx][ny] == '1')
dfs(nx, ny);
}
return;
}
int main() {
while (1) {
for (auto &i : maap)
for (auto &j : i) {
cin >> j;
if (cin.eof())
return 0;
}
int cnt = 0;
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
if (maap[i][j] == '1') {
dfs(i, j);
cnt++;
}
cout << cnt << endl;
}
return 0;
}
|
#include <array>
#include <iostream>
using namespace std;
array<array<char, 12>, 12> maap;
void dfs(int x, int y) {
maap[x][y] = '0';
int dx[] = {0, -1, 1, 0}, dy[] = {1, 0, 0, -1};
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && maap[nx][ny] == '1')
dfs(nx, ny);
}
return;
}
int main() {
while (1) {
for (auto &i : maap)
for (auto &j : i) {
cin >> j;
if (cin.eof())
return 0;
}
int cnt = 0;
for (int i = 0; i < 12; i++)
for (int j = 0; j < 12; j++)
if (maap[i][j] == '1') {
dfs(i, j);
cnt++;
}
cout << cnt << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22]]
| 1
| 260
| 2
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define INF 114514
using namespace std;
int main() {
while (1) {
double h, x;
cin >> x >> h;
if (x == 0 && h == 0)
return 0;
printf("%.6f", x * x + sqrt(x / 2 * x / 2 + h * h) * 2 * x);
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define INF 114514
using namespace std;
int main() {
while (1) {
double h, x;
cin >> x >> h;
if (x == 0 && h == 0)
return 0;
printf("%.6f\n", x * x + sqrt(x / 2 * x / 2 + h * h) * 2 * x);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 117
| 1
|
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
double x, h;
while (1) {
scanf("%lf %lf", &x, &h);
if (x + h == 0)
break;
else
printf("%lf", (x * x) + 2 * x * sqrt((h * h) + ((x / 2) * (x / 2))));
}
return 0;
}
|
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
double x, h;
while (1) {
scanf("%lf %lf", &x, &h);
if (x + h == 0)
break;
else
printf("%lf\n", (x * x) + 2 * x * sqrt((h * h) + ((x / 2) * (x / 2))));
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 94
| 1
|
#!/usr/bin/env ruby
while (x = gets.to_f, h = gets.to_f) != [0, 0]
hh = (x / 2 * x / 2 + h * h) ** 0.5
puts format '%.6f', x * x + x * hh * 2
end
|
while (x, h = gets.to_f, gets.to_f) != [0, 0]
hh = (x / 2 * x / 2 + h * h) ** 0.5
puts format '%.6f', x * x + x * hh * 2
end
|
[["+", 15, 738, 31, 739, 0, 662, 31, 761, 0, 21], ["+", 15, 738, 31, 739, 0, 662, 31, 761, 0, 22], ["-", 31, 739, 0, 662, 12, 762, 0, 662, 31, 22], ["-", 31, 739, 0, 662, 12, 762, 0, 662, 0, 32]]
| 4
| 54
| 4
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
int h = scanner.nextInt();
int m = scanner.nextInt();
int s = scanner.nextInt();
if (h == -1 && m == -1 && s == 0) {
break;
}
int sc = 7200 - (h * 3600 + m * 60 + s);
int sc3 = sc * 3;
System.out.println(
String.format("%02d:%02d:%02d", sc / 3600, sc / 60 % 60, sc % 60));
System.out.println(
String.format("%02d:%02d:%02d", sc3 / 3600, sc3 / 60 % 60, sc3 % 60));
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
int h = scanner.nextInt();
int m = scanner.nextInt();
int s = scanner.nextInt();
if (h == -1 && m == -1 && s == -1) {
break;
}
int sc = 7200 - (h * 3600 + m * 60 + s);
int sc3 = sc * 3;
System.out.println(
String.format("%02d:%02d:%02d", sc / 3600, sc / 60 % 60, sc % 60));
System.out.println(
String.format("%02d:%02d:%02d", sc3 / 3600, sc3 / 60 % 60, sc3 % 60));
}
}
}
|
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499], ["+", 15, 15, 0, 16, 12, 16, 12, 91, 17, 33], ["+", 15, 15, 0, 16, 12, 16, 12, 91, 439, 499]]
| 3
| 172
| 3
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt(), d = sc.nextInt(), s = sc.nextInt();
if (h == -1 & d == -1 & s == -1)
break;
int sum = h * 3600 + d * 60 + s;
int ans1 = 2 * 3600 - sum;
int ans2 = 2 * 3600 - sum / 3;
System.out.printf("%02d:%02d:%02d\n", ans1 / 3600, ans1 % 3600 / 60,
ans1 % 60);
System.out.printf("%02d:%02d:%02d\n", ans2 / 3600, ans2 % 3600 / 60,
ans2 % 60);
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt(), d = sc.nextInt(), s = sc.nextInt();
if (h == -1 & d == -1 & s == -1)
break;
int sum = h * 3600 + d * 60 + s;
int ans1 = 2 * 3600 - sum;
int ans2 = 2 * 3600 * 3 - sum * 3;
System.out.printf("%02d:%02d:%02d\n", ans1 / 3600, ans1 % 3600 / 60,
ans1 % 60);
System.out.printf("%02d:%02d:%02d\n", ans2 / 3600, ans2 % 3600 / 60,
ans2 % 60);
}
}
}
|
[["+", 0, 503, 49, 200, 51, 16, 31, 16, 17, 48], ["+", 0, 503, 49, 200, 51, 16, 31, 16, 12, 499], ["-", 0, 503, 49, 200, 51, 16, 12, 16, 17, 85], ["+", 0, 503, 49, 200, 51, 16, 12, 16, 17, 48]]
| 3
| 170
| 4
|
import java.util.Scanner;
// Videotape
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
if (h == -1)
break;
int x = h * 3600 + m * 60 + s;
int r = 7200 - x;
int r3 = 7200 - x / 3;
// r3 /= 3;
if (r < 0)
r = 0;
if (r3 < 0)
r3 = 0;
int h1 = r / 3600;
r %= 3600;
int m1 = r / 60;
r %= 60;
int h2 = r3 / 3600;
r3 %= 3600;
int m2 = r3 / 60;
r3 %= 60;
System.out.printf("%02d:%02d:%02d\n", h1, m1, r);
System.out.printf("%02d:%02d:%02d\n", h2, m2, r3);
}
}
}
|
import java.util.Scanner;
// Videotape
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
if (h == -1)
break;
int x = h * 3600 + m * 60 + s;
int r = 7200 - x;
int r3 = 7200 * 3 - x * 3;
if (r < 0)
r = 0;
if (r3 < 0)
r3 = 0;
int h1 = r / 3600;
r %= 3600;
int m1 = r / 60;
r %= 60;
int h2 = r3 / 3600;
r3 %= 3600;
int m2 = r3 / 60;
r3 %= 60;
System.out.printf("%02d:%02d:%02d\n", h1, m1, r);
System.out.printf("%02d:%02d:%02d\n", h2, m2, r3);
}
}
}
|
[["+", 0, 503, 49, 200, 51, 16, 31, 16, 17, 48], ["+", 0, 503, 49, 200, 51, 16, 31, 16, 12, 499], ["-", 0, 503, 49, 200, 51, 16, 12, 16, 17, 85], ["+", 0, 503, 49, 200, 51, 16, 12, 16, 17, 48]]
| 3
| 208
| 4
|
import java.util.Scanner;
// Videotape
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
if (h == -1)
break;
int x = h * 3600 + m * 60 + s;
int r = 7200 - x;
int r3 = 7200 * 3 - x;
r3 /= 3;
System.out.printf("%02d:%02d:%02d\n", r / 3600, r % 3600 / 60, r % 60);
System.out.printf("%02d:%02d:%02d\n", r3 / 3600, r3 % 3600 / 60, r3 % 60);
}
}
}
|
import java.util.Scanner;
// Videotape
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int h = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
if (h == -1)
break;
int x = h * 3600 + m * 60 + s;
int r = 7200 - x;
int r3 = 7200 * 3 - x * 3;
System.out.printf("%02d:%02d:%02d\n", r / 3600, r % 3600 / 60, r % 60);
System.out.printf("%02d:%02d:%02d\n", r3 / 3600, r3 % 3600 / 60, r3 % 60);
}
}
}
|
[["-", 8, 196, 0, 52, 8, 196, 0, 503, 0, 35], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 17, 90], ["+", 0, 503, 49, 200, 51, 16, 12, 16, 17, 48]]
| 3
| 163
| 4
|
import java.awt.geom.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
private void doit() {
Scanner sc = new Scanner(System.in);
int max = 2 * 3600;
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a < 0 && b < 0 && c < 0)
break;
int time = a * 3600 + b * 60 + c;
int rest = max - time;
int ansc = rest % 60;
int ansb = rest % 3600 / 60;
int ansa = rest / 3600;
System.out.printf("%02d:%02d:%02d\n", ansa, ansb, ansc);
rest = max - time / 3;
ansc = rest % 60;
ansb = rest % 3600 / 60;
ansa = rest / 3600;
System.out.printf("%02d:%02d:%02d\n", ansa, ansb, ansc);
}
}
public static void main(String[] args) {
Main obj = new Main();
obj.doit();
}
}
|
import java.awt.geom.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
private void doit() {
Scanner sc = new Scanner(System.in);
int max = 2 * 3600;
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a < 0 && b < 0 && c < 0)
break;
int time = a * 3600 + b * 60 + c;
int rest = max - time;
int ansc = rest % 60;
int ansb = rest % 3600 / 60;
int ansa = rest / 3600;
System.out.printf("%02d:%02d:%02d\n", ansa, ansb, ansc);
rest = rest * 3;
ansc = rest % 60;
ansb = rest % 3600 / 60;
ansa = rest / 3600;
System.out.printf("%02d:%02d:%02d\n", ansa, ansb, ansc);
}
}
public static void main(String[] args) {
Main obj = new Main();
obj.doit();
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48]]
| 3
| 242
| 6
|
#include <stdio.h>
int main(void) {
int t, h, s, tmp, at, ah, as;
while (1) {
scanf("%d %d %d", &t, &h, &s);
if (t < 0)
break;
tmp = 2 * 3600 - (t * 3600 + h * 60 + s);
at = tmp / 3600;
tmp %= 3600;
ah = tmp / 60;
as = tmp % 60;
printf("%02d:%02d:%02d\n", at, ah, as);
tmp = 2 * 3600 - ((t * 3600 + h * 60 + s)) / 3;
at = tmp / 3600;
tmp %= 3600;
ah = tmp / 60;
as = tmp % 60;
printf("%02d:%02d:%02d\n", at, ah, as);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int t, h, s, tmp, at, ah, as;
while (1) {
scanf("%d %d %d", &t, &h, &s);
if (t < 0)
break;
tmp = 2 * 3600 - (t * 3600 + h * 60 + s);
at = tmp / 3600;
tmp %= 3600;
ah = tmp / 60;
as = tmp % 60;
printf("%02d:%02d:%02d\n", at, ah, as);
tmp = (2 * 3600 - (t * 3600 + h * 60 + s)) * 3;
at = tmp / 3600;
tmp %= 3600;
ah = tmp / 60;
as = tmp % 60;
printf("%02d:%02d:%02d\n", at, ah, as);
}
return 0;
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48]]
| 0
| 169
| 4
|
#include <stdio.h>
int main(void) {
int t, h, s, m, h3, m3, s3;
while (1) {
scanf("%d %d %d", &t, &h, &s);
if ((t == -1) && (h == -1) && (s == -1))
break;
m = (t * 60 + h) * 60 + s;
m3 = 7200 - (m / 3);
s3 = m3 % 60;
h3 = (m3 / 60) / 60;
m3 = (m3 / 60) % 60;
m = 7200 - m;
s = m % 60;
h = (m / 60) / 60;
m = (m / 60) % 60;
printf("%02d:%02d:%02d\n", h, m, s);
printf("%02d:%02d:%02d\n", h3, m3, s3);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int t, h, s, m, h3, m3, s3;
while (1) {
scanf("%d %d %d", &t, &h, &s);
if ((t == -1) && (h == -1) && (s == -1))
break;
m = (t * 60 + h) * 60 + s;
m3 = (7200 - m) * 3;
s3 = m3 % 60;
h3 = (m3 / 60) / 60;
m3 = (m3 / 60) % 60;
m = 7200 - m;
s = m % 60;
h = (m / 60) / 60;
m = (m / 60) % 60;
printf("%02d:%02d:%02d\n", h, m, s);
printf("%02d:%02d:%02d\n", h3, m3, s3);
}
return 0;
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 0
| 181
| 6
|
main(h, m, s) {
for (; scanf("%d%d%d", &h, &m, &s), ~h;) {
int left = 7200 - 60 * (60 * h + m) + s;
printf("%02d:%02d:%02d\n", left / 3600, left % 3600 / 60, left % 60);
left *= 3;
printf("%02d:%02d:%02d\n", left / 3600, left % 3600 / 60, left % 60);
}
exit(0);
}
|
main(h, m, s) {
for (; scanf("%d%d%d", &h, &m, &s), ~h;) {
int left = 7200 - (60 * (60 * h + m) + s);
printf("%02d:%02d:%02d\n", left / 3600, left % 3600 / 60, left % 60);
left *= 3;
printf("%02d:%02d:%02d\n", left / 3600, left % 3600 / 60, left % 60);
}
exit(0);
}
|
[["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
| 0
| 106
| 2
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
if (a == -1)
break;
int sum = 120 * 60 - (a * 60 + b) * 60 + c;
int sum2 = sum * 3;
vector<int> s;
rep(i, 3) {
s.push_back(sum % 60);
sum /= 60;
}
vector<int> s2;
rep(i, 3) {
s2.push_back(sum2 % 60);
sum2 /= 60;
}
printf("%02d:%02d:%02d\n", s[2], s[1], s[0]);
printf("%02d:%02d:%02d\n", s2[2], s2[1], s2[0]);
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define reps(i, f, n) for (int i = f; i < int(n); i++)
#define rep(i, n) reps(i, 0, n)
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
if (a == -1)
break;
int sum = 120 * 60 - ((a * 60 + b) * 60 + c);
int sum2 = sum * 3;
vector<int> s;
rep(i, 3) {
s.push_back(sum % 60);
sum /= 60;
}
vector<int> s2;
rep(i, 3) {
s2.push_back(sum2 % 60);
sum2 /= 60;
}
printf("%02d:%02d:%02d\n", s[2], s[1], s[0]);
printf("%02d:%02d:%02d\n", s2[2], s2[1], s2[0]);
}
}
|
[["+", 12, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
| 1
| 205
| 2
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int H, M, S;
while (cin >> H >> M >> S, H != -1 && M != -1 && S != -1) {
S += M * 60 + H * 3600;
S = 2 * 3600 - S;
printf("%02d:%02d:%02d\n", S / 3600, S / 60, S % 60);
S *= 3;
printf("%02d:%02d:%02d\n", S / 3600, S / 60 % 60, S % 60);
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int H, M, S;
while (cin >> H >> M >> S, H != -1 && M != -1 && S != -1) {
S += M * 60 + H * 3600;
S = 2 * 3600 - S;
printf("%02d:%02d:%02d\n", S / 3600, S / 60 % 60, S % 60);
S *= 3;
printf("%02d:%02d:%02d\n", S / 3600, S / 60 % 60, S % 60);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 114
| 2
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c, a != -1 || b != -1 || c != -1) {
int now = a * 3600 + b * 60 + c;
int ans = 7200 - now;
cout << "0" << ans / 3600 << ":";
if (ans % 3600 / 60 < 10)
cout << "0";
cout << ans % 3600 / 60 << ":";
if (ans % 60 < 10)
cout << "0";
cout << ans % 60 << endl;
ans = 7200 - (now / 3);
cout << "0" << ans / 3600 << ":";
if (ans % 3600 / 60 < 10)
cout << "0";
cout << ans % 3600 / 60 << ":";
if (ans % 60 < 10)
cout << "0";
cout << ans % 60 << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c, a != -1 || b != -1 || c != -1) {
int now = a * 3600 + b * 60 + c;
int ans = 7200 - now;
cout << "0" << ans / 3600 << ":";
if (ans % 3600 / 60 < 10)
cout << "0";
cout << ans % 3600 / 60 << ":";
if (ans % 60 < 10)
cout << "0";
cout << ans % 60 << endl;
ans = (7200 - now) * 3;
cout << "0" << ans / 3600 << ":";
if (ans % 3600 / 60 < 10)
cout << "0";
cout << ans % 3600 / 60 << ":";
if (ans % 60 < 10)
cout << "0";
cout << ans % 60 << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 1
| 204
| 6
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define rp(a) while (a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
int a, b, c;
while (cin >> a >> b >> c, a + 1) {
int sum = a * 3600 + b * 60 + c;
int out = 7200 - sum;
printf("%02d:%02d:%02d\n", out / 3600, (out % 3600) / 60, out % 60);
out = 7200 - sum / 3;
printf("%02d:%02d:%02d\n", out / 3600, (out % 3600) / 60, out % 60);
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define rp(a) while (a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
int a, b, c;
while (cin >> a >> b >> c, a + 1) {
int sum = a * 3600 + b * 60 + c;
int out = 7200 - sum;
printf("%02d:%02d:%02d\n", out / 3600, (out % 3600) / 60, out % 60);
/*double tmp=sum/3.0;
if(tmp-(int)tmp)tmp++;
out=7200-(int)tmp;*/
out *= 3;
printf("%02d:%02d:%02d\n", out / 3600, (out % 3600) / 60, out % 60);
}
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108]]
| 1
| 194
| 6
|
#include <cstdio>
using namespace std;
int main() {
int h, m, s;
while (1) {
int tmp;
int stan, stan_3;
scanf("%d %d %d", &h, &m, &s);
if (h == -1 && m == -1 && s == -1) {
break;
}
tmp = h * 3600 + m * 60 + s;
// printf("tmp=%d\n", tmp);
stan = 7200 - tmp;
stan_3 = 7200 - (tmp / 3);
int h_2, m_2, s_2;
h_2 = stan / 3600;
// printf("h_2 = %d\n", h_2);
m_2 = (stan - 3600 * h_2) / 60;
s_2 = (stan - 3600 * h_2 - 60 * m_2);
// printf("s_2=%d\n", s_2);
printf("%02d:%02d:%02d\n", h_2, m_2, s_2);
int h_3, m_3, s_3;
h_3 = stan_3 / 3600;
m_3 = (stan_3 - 3600 * h_3) / 60;
s_3 = (stan_3 - 3600 * h_3 - 60 * m_3);
printf("%02d:%02d:%02d\n", h_3, m_3, s_3);
}
return (0);
}
|
#include <cstdio>
using namespace std;
int main() {
int h, m, s;
while (1) {
int tmp;
int stan, stan_3;
scanf("%d %d %d", &h, &m, &s);
if (h == -1 && m == -1 && s == -1) {
break;
}
tmp = h * 3600 + m * 60 + s;
// printf("tmp=%d\n", tmp);
stan = 7200 - tmp;
stan_3 = stan * 3;
int h_2, m_2, s_2;
h_2 = stan / 3600;
// printf("h_2 = %d\n", h_2);
m_2 = (stan - 3600 * h_2) / 60;
s_2 = (stan - 3600 * h_2 - 60 * m_2);
// printf("s_2=%d\n", s_2);
printf("%02d:%02d:%02d\n", h_2, m_2, s_2);
int h_3, m_3, s_3;
h_3 = stan_3 / 3600;
m_3 = (stan_3 - 3600 * h_3) / 60;
s_3 = (stan_3 - 3600 * h_3 - 60 * m_3);
printf("%02d:%02d:%02d\n", h_3, m_3, s_3);
}
return (0);
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 1
| 209
| 8
|
#include <cstdio>
#include <iostream>
using namespace std;
int s[3], t[3], u[3], _time, vtime;
void printtime(int sec) {
printf("%02d;%02d:%02d\n", sec / 3600, (sec / 60) % 60, sec % 60);
}
int main() {
while (true) {
cin >> s[0] >> s[1] >> s[2];
if (s[0] == -1) {
break;
}
_time = s[0] * 3600 + s[1] * 60 + s[2];
vtime = 7200;
printtime(vtime - _time);
printtime(vtime * 3 - _time * 3);
}
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int s[3], t[3], u[3], _time, vtime;
void printtime(int sec) {
printf("%02d:%02d:%02d\n", sec / 3600, (sec / 60) % 60, sec % 60);
}
int main() {
while (true) {
cin >> s[0] >> s[1] >> s[2];
if (s[0] == -1) {
break;
}
_time = s[0] * 3600 + s[1] * 60 + s[2];
vtime = 7200;
printtime(vtime - _time);
printtime(vtime * 3 - _time * 3);
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 145
| 2
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
int h, m, s, t;
int main() {
while (cin >> h >> m >> s) {
if (h == -1 && m == -1 && s == -1)
break;
int sum = 3600 * h + 60 * m + s, t1 = 7200 - sum, t2 = 7200 - sum / 3;
printf("%02d:%02d:%02d\n", t1 / 3600, t1 % 3600 / 60, t1 % 60);
printf("%02d:%02d:%02d\n", t2 / 3600, t2 % 3600 / 60, t2 % 60);
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
int h, m, s, t;
int main() {
while (cin >> h >> m >> s) {
if (h == -1 && m == -1 && s == -1)
break;
int sum = 3600 * h + 60 * m + s, t1 = 7200 - sum, t2 = t1 * 3;
printf("%02d:%02d:%02d\n", t1 / 3600, t1 % 3600 / 60, t1 % 60);
printf("%02d:%02d:%02d\n", t2 / 3600, t2 % 3600 / 60, t2 % 60);
}
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 16, 12, 16, 17, 85], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48]]
| 1
| 223
| 6
|
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = a; i >= n; i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
int main() {
int t, h, s;
while (cin >> t >> h >> s) {
while (t == -1 && h == -1 && s == -1)
break;
int temp = 7200 - (3600 * t + 60 * h + s);
int a, b, c;
a = temp / 3600;
b = temp / 60 % 60;
c = temp % 60;
printf("%02d:%02d:%02d\n", a, b, c);
temp *= 3;
a = temp / 3600;
b = temp / 60 % 60;
c = temp % 60;
printf("%02d:%02d:%02d\n", a, b, c);
}
return 0;
}
|
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = a; i >= n; i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
int main() {
int t, h, s;
while (cin >> t >> h >> s) {
if (t == -1 && h == -1 && s == -1)
break;
int temp = 7200 - (3600 * t + 60 * h + s);
int a, b, c;
a = temp / 3600;
b = temp / 60 % 60;
c = temp % 60;
printf("%02d:%02d:%02d\n", a, b, c);
temp *= 3;
a = temp / 3600;
b = temp / 60 % 60;
c = temp % 60;
printf("%02d:%02d:%02d\n", a, b, c);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 8, 9, 0, 52, 0, 89], ["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121]]
| 1
| 193
| 2
|
#include <cstdio>
using namespace std;
int main() {
int t, h, s, max = 2 * 60 * 60;
while (scanf("%d %d %d", &t, &h, &s) && t != -1) {
int ss = max - (s + h * 60 + t * 60 * 60);
printf("%02d:%02d:%02d\n", ss / 60 / 60, ss / 60, ss % 60);
ss *= 3;
printf("%02d:%02d:%02d\n", ss / 60 / 60, ss / 60 % 60, ss % 60);
}
return 0;
}
|
#include <cstdio>
using namespace std;
int main() {
int t, h, s, max = 2 * 60 * 60;
while (scanf("%d %d %d", &t, &h, &s) && t != -1) {
int ss = max - (s + h * 60 + t * 60 * 60);
printf("%02d:%02d:%02d\n", ss / 60 / 60, ss / 60 % 60, ss % 60);
ss *= 3;
printf("%02d:%02d:%02d\n", ss / 60 / 60, ss / 60 % 60, ss % 60);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 123
| 2
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PA;
using namespace std;
#define MAX 999999
int main() {
int h, m, s;
while (cin >> h >> m >> s, !(h + m + s == -3)) {
int r = 3600 * 2 - (h * 3600 + m * 60 + s);
int hoge = 3 * r;
int th = r / 3600;
r %= 3600;
int tm = r / 60;
r %= 60;
int ts = r;
printf("%02d:%02d:%02d\n", th, tm, ts);
th = hoge / 3600;
hoge %= 3600;
tm = hoge / 60;
hoge %= 60;
ts = r;
printf("%02d:%02d:%02d\n", th, tm, ts);
}
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int> PA;
using namespace std;
#define MAX 999999
int main() {
int h, m, s;
while (cin >> h >> m >> s, !(h + m + s == -3)) {
int r = 3600 * 2 - (h * 3600 + m * 60 + s);
int hoge = 3 * r;
int th = r / 3600;
r %= 3600;
int tm = r / 60;
r %= 60;
int ts = r;
printf("%02d:%02d:%02d\n", th, tm, ts);
th = hoge / 3600;
hoge %= 3600;
tm = hoge / 60;
hoge %= 60;
ts = hoge;
printf("%02d:%02d:%02d\n", th, tm, ts);
}
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 240
| 2
|
#include "bits/stdc++.h"
using namespace std;
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
if (a == -1 || b == -1 || c == -1)
break;
int second = 7200 - (a * 3600 + b * 60 + c);
printf("%02d:%02d:%02d\n", second / 3600, second / 60, second % 60);
second = second * 3;
printf("%02d:%02d:%02d\n", second / 3600, second / 60 % 60, second % 60);
}
}
|
#include "bits/stdc++.h"
using namespace std;
using namespace std;
int main() {
int a, b, c;
while (cin >> a >> b >> c) {
if (a == -1 || b == -1 || c == -1)
break;
int second = 7200 - (a * 3600 + b * 60 + c);
printf("%02d:%02d:%02d\n", second / 3600, second / 60 % 60, second % 60);
second = second * 3;
printf("%02d:%02d:%02d\n", second / 3600, second / 60 % 60, second % 60);
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 118
| 2
|
#include <stdio.h>
int main() {
int t, h, s, sum;
while (scanf("%d %d %d", &t, &h, &s), t != -1 && h != -1 && s != -1) {
sum = 120 * 60 - t * 3600 - h * 60 - s;
printf("%02d:%02d:%02d\n", sum / 3600, sum / 60, sum % 60);
sum *= 3;
printf("%02d:%02d:%02d\n", sum / 3600, (sum / 60) % 60, sum % 60);
}
return (0);
}
|
#include <stdio.h>
int main() {
int t, h, s, sum;
while (scanf("%d %d %d", &t, &h, &s), t != -1 && h != -1 && s != -1) {
sum = 120 * 60 - t * 3600 - h * 60 - s;
printf("%02d:%02d:%02d\n", sum / 3600, (sum / 60) % 60, sum % 60);
sum *= 3;
printf("%02d:%02d:%02d\n", sum / 3600, (sum / 60) % 60, sum % 60);
}
return (0);
}
|
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109]]
| 1
| 118
| 4
|
#include <cstdio>
using namespace std;
int main() {
int h, m, s, r1, r3;
while (scanf("%d %d %d", &h, &m, &s), h != -1 && m != -1 && s != -1) {
r1 = 120 * 60 - ((h * 60) + m) * 60 + s;
r3 = r1 * 3;
printf("%02d:%02d:%02d\n", r1 / 3600, (r1 / 60) % 60, r1 % 60);
printf("%02d:%02d:%02d\n", r3 / 3600, (r3 / 60) % 60, r3 % 60);
}
}
|
#include <cstdio>
using namespace std;
int main() {
int h, m, s, r1, r3;
while (scanf("%d %d %d", &h, &m, &s), h != -1 && m != -1 && s != -1) {
r1 = 120 * 60 - (((h * 60) + m) * 60 + s);
r3 = r1 * 3;
printf("%02d:%02d:%02d\n", r1 / 3600, (r1 / 60) % 60, r1 % 60);
printf("%02d:%02d:%02d\n", r3 / 3600, (r3 / 60) % 60, r3 % 60);
}
}
|
[["+", 31, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 1
| 129
| 2
|
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
void printTime(int sec) {
printf("%02d:%02d:%02d\n", sec / 3600, sec / 60 % 60, sec % 60);
}
int main() {
while (true) {
int h, m, s;
scanf("%d %d %d\n", &h, &m, &s);
if (h == -1 && m == -1 && s == -1)
break;
const int VideoLen = 2 * 3600;
int sec = h * 3600 + m * 60 + s;
printTime(VideoLen - sec);
printTime(VideoLen - sec / 3);
}
return 0;
}
|
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
void printTime(int sec) {
printf("%02d:%02d:%02d\n", sec / 3600, sec / 60 % 60, sec % 60);
}
int main() {
while (true) {
int h, m, s;
scanf("%d %d %d\n", &h, &m, &s);
if (h == -1 && m == -1 && s == -1)
break;
const int VideoLen = 2 * 3600;
int sec = h * 3600 + m * 60 + s;
printTime(VideoLen - sec);
printTime(VideoLen * 3 - sec * 3);
}
return 0;
}
|
[["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 16, 12, 16, 17, 85], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 48]]
| 1
| 154
| 4
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int toSec(int h, int m, int s) { return (h * 60 + m) * 60 + s; }
vector<int> toHms(int sec) {
vector<int> v;
v.push_back(sec / (60 * 60));
sec -= v[0] * 60 * 60;
v.push_back(sec / 60);
v.push_back(sec - v[1] * 60);
return v;
}
int main() {
int h, m, s;
while (cin >> h >> m >> s) {
if (h == -1 && m == -1 && s == -1)
break;
int sec = toSec(h, m, s);
vector<int> v[2];
v[0] = toHms(toSec(2, 0, 0) - sec);
v[1] = toHms(toSec(3, 0, 0) - sec);
for (int i = 0; i < 2; ++i) {
printf("%02d:%02d:%02d\n", v[i][0], v[i][1], v[i][2]);
}
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int toSec(int h, int m, int s) { return (h * 60 + m) * 60 + s; }
vector<int> toHms(int sec) {
vector<int> v;
v.push_back(sec / (60 * 60));
sec -= v[0] * 60 * 60;
v.push_back(sec / 60);
v.push_back(sec - v[1] * 60);
return v;
}
int main() {
int h, m, s;
while (cin >> h >> m >> s) {
if (h == -1 && m == -1 && s == -1)
break;
int sec = toSec(h, m, s);
vector<int> v[2];
v[0] = toHms(toSec(2, 0, 0) - sec);
v[1] = toHms((toSec(2, 0, 0) - sec) * 3);
for (int i = 0; i < 2; ++i) {
printf("%02d:%02d:%02d\n", v[i][0], v[i][1], v[i][2]);
}
}
return 0;
}
|
[["+", 12, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 16, 31, 2, 3, 4, 0, 13], ["+", 31, 23, 0, 16, 31, 2, 3, 4, 0, 13], ["+", 12, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 257
| 6
|
#include <cstdio>
int h, m, s;
main() {
while (scanf("%d%d%d", &h, &m, &s) && h != -1) {
int r = 7200 - (h * 60 + m) * 60 + s;
for (int i = 0; i < 2; i++, r *= 3) {
printf("%02d:%02d:%02d\n", r / 60 / 60, (r / 60) % 60, r % 60);
}
}
return 0;
}
|
#include <cstdio>
int h, m, s;
main() {
while (scanf("%d%d%d", &h, &m, &s) && h != -1) {
int r = 7200 - (h * 60 + m) * 60 - s;
for (int i = 0; i < 2; i++, r *= 3) {
printf("%02d:%02d:%02d\n", r / 60 / 60, (r / 60) % 60, r % 60);
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33]]
| 1
| 104
| 2
|
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define Iter(c) __typeof__((c).begin())
#define foreach(i, c) for (Iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int Clock(int h, int m, int s) { return h * 3600 + m * 60 + s; }
string itos(int i) {
stringstream ss;
ss << i;
return ss.str();
}
void print(int Time) {
int h, m, s;
h = Time / 3600;
Time -= Time / 3600 * 3600;
m = Time / 60;
Time -= Time / 60 * 60;
s = Time;
string ele[3];
ele[0] = itos(h);
ele[1] = itos(m);
ele[2] = itos(s);
cout << string(2 - ele[0].length(), '0') << ele[0] << ":"
<< string(2 - ele[1].length(), '0') << ele[1] << ":"
<< string(2 - ele[2].length(), '0') << ele[2] << endl;
}
int main() {
int h, m, s;
while (true) {
cin >> h >> m >> s;
if (h + m + s == -3)
break;
int TimeX = Clock(2, 0, 0);
int Time = Clock(h, m, s);
print(TimeX - Time);
print(TimeX - Time / 3);
}
return 0;
}
|
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
#define all(n) n.begin(), n.end()
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define insert(a, b, c, d) PP(P(a, b), P(c, d))
#define F first
#define S second
#define Iter(c) __typeof__((c).begin())
#define foreach(i, c) for (Iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define INF (1 << 27)
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int Clock(int h, int m, int s) { return h * 3600 + m * 60 + s; }
string itos(int i) {
stringstream ss;
ss << i;
return ss.str();
}
void print(int Time) {
int h, m, s;
h = Time / 3600;
Time -= Time / 3600 * 3600;
m = Time / 60;
Time -= Time / 60 * 60;
s = Time;
string ele[3];
ele[0] = itos(h);
ele[1] = itos(m);
ele[2] = itos(s);
cout << string(2 - ele[0].length(), '0') << ele[0] << ":"
<< string(2 - ele[1].length(), '0') << ele[1] << ":"
<< string(2 - ele[2].length(), '0') << ele[2] << endl;
}
int main() {
int h, m, s;
while (true) {
cin >> h >> m >> s;
if (h + m + s == -3)
break;
int TimeX = Clock(2, 0, 0);
int Time = Clock(h, m, s);
print(TimeX - Time);
print((TimeX - Time) * 3);
}
return 0;
}
|
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 0, 2, 3, 4, 0, 16, 12, 16, 17, 85], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
| 1
| 467
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void print_hms(int sec) {
int h, m, s;
s = sec % 60;
m = (sec / 60) % 60;
h = sec / 3600;
printf("%02d:%02d:%02d\n", h, m, s);
}
int main() {
int h, m, s;
while (cin >> h >> m >> s, s != -1) {
const int twh = 7200;
int sec;
sec = h * 60 * 60 + m * 60 + s;
print_hms(twh - sec);
print_hms(twh - sec / 3);
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void print_hms(int sec) {
int h, m, s;
s = sec % 60;
m = (sec / 60) % 60;
h = sec / 3600;
printf("%02d:%02d:%02d\n", h, m, s);
}
int main() {
int h, m, s;
while (cin >> h >> m >> s, s != -1) {
const int twh = 7200;
int sec;
sec = h * 60 * 60 + m * 60 + s;
print_hms(twh - sec);
print_hms((twh - sec) * 3);
}
return 0;
}
|
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["-", 0, 2, 3, 4, 0, 16, 12, 16, 17, 85], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
| 1
| 180
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int h, m, s, total, h1, m1, s1, total1;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1) {
break;
}
total1 = h * 3600 + m * 60 + s;
total1 = 120 * 60 - total1;
total1 *= 3;
total = h * 3600 + m * 60 + s;
total = 120 * 60 - total;
h = total / 3600;
total %= 3600;
m = total / 60;
total %= 60;
s = total;
h1 = total1 / 3600;
total1 %= 3600;
m1 = total1 / 60;
total1 %= 60;
s1 = total;
printf("%02d:%02d:%02d\n", h, m, s);
printf("%02d:%02d:%02d\n", h1, m1, s1);
}
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int h, m, s, total, h1, m1, s1, total1;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1) {
break;
}
total1 = h * 3600 + m * 60 + s;
total1 = 120 * 60 - total1;
total1 *= 3;
total = h * 3600 + m * 60 + s;
total = 120 * 60 - total;
h = total / 3600;
total %= 3600;
m = total / 60;
total %= 60;
s = total;
h1 = total1 / 3600;
total1 %= 3600;
m1 = total1 / 60;
total1 %= 60;
s1 = total1;
printf("%02d:%02d:%02d\n", h, m, s);
printf("%02d:%02d:%02d\n", h1, m1, s1);
}
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 183
| 2
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h, m, s;
int time;
int nokori, nokori3;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1) {
break;
}
time = 3600 * h + 60 * m + s;
nokori = 7200 - time;
nokori3 = 7200 - (time / 3);
printf("%02d:", nokori / 3600);
nokori %= 3600;
printf("%02d:", nokori / 60);
nokori %= 60;
printf("%02d\n", nokori);
printf("%02d:", nokori3 / 3600);
nokori3 %= 3600;
printf("%02d:", nokori3 / 60);
nokori3 %= 60;
printf("%02d\n", nokori3);
}
return 0;
}
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int h, m, s;
int time;
int nokori, nokori3;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1) {
break;
}
time = 3600 * h + 60 * m + s;
nokori = 7200 - time;
nokori3 = nokori * 3;
printf("%02d:", nokori / 3600);
nokori %= 3600;
printf("%02d:", nokori / 60);
nokori %= 60;
printf("%02d\n", nokori);
printf("%02d:", nokori3 / 3600);
nokori3 %= 3600;
printf("%02d:", nokori3 / 60);
nokori3 %= 60;
printf("%02d\n", nokori3);
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 1
| 172
| 8
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
int main() {
int h, m, s;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1)
break;
int sum = h * 60 * 60 + m * 60 + s;
int rest = 120 * 60 - sum;
int ah, am, as;
ah = rest / 3600;
rest %= 3600;
am = rest / 60;
rest %= 60;
as = rest;
printf("%02d:%02d:%02d\n", ah, am, as);
sum /= 3;
rest = 120 * 60 - sum;
ah = rest / 3600;
rest %= 3600;
am = rest / 60;
rest %= 60;
as = rest;
printf("%02d:%02d:%02d\n", ah, am, as);
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));
#define for_(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define for_d(i, a, b) for (int i = (int)a - 1; i >= b; i--)
#define for_r(i, a, b, c) for (int i = (int)a; i < (int)b; i += c)
#define for_dr(i, a, b, c) for (int i = (int)a - 1; i >= b; i -= c)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;
typedef double D;
const int iINF = 2147483647;
const ll lINF = 9223372036854775807;
template <class T> inline void dbg(T t) { cout << t << endl; }
int main() {
int h, m, s;
while (1) {
cin >> h >> m >> s;
if (h == -1 && m == -1 && s == -1)
break;
int sum = h * 60 * 60 + m * 60 + s;
int rest = 120 * 60 - sum;
int ah, am, as;
ah = rest / 3600;
rest %= 3600;
am = rest / 60;
rest %= 60;
as = rest;
printf("%02d:%02d:%02d\n", ah, am, as);
sum *= 3;
rest = 120 * 60 * 3 - sum;
ah = rest / 3600;
rest %= 3600;
am = rest / 60;
rest %= 60;
as = rest;
printf("%02d:%02d:%02d\n", ah, am, as);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13]]
| 1
| 330
| 4
|
loop do
record_time=2*3600#????????§???????§???°
time=gets.chomp.split(nil).map(&:to_i)
break if time.all?{|x|x==-1}
t=time[2]
t+=time[1]*60
t+=time[0]*3600
#?¨??????????
rest_of_time=record_time-t
h=rest_of_time/3600#hour
m=(rest_of_time%3600)/60#minute
s=rest_of_time%60#second
printf("%02d:%02d:%02d \n",h,m,s)
#3???????????¢??????
rest_of_time=record_time-t/3
h=rest_of_time/3600#hour
m=(rest_of_time%3600)/60#minute
s=rest_of_time%60#second
printf("%02d:%02d:%02d \n",h,m,s)
end
|
loop do
record_time=2*3600#????????§???????§???°
time=gets.chomp.split(nil).map(&:to_i)
break if time.all?{|x|x==-1}
t=time[2]
t+=time[1]*60
t+=time[0]*3600
#?¨??????????
rest_of_time=record_time-t
h=rest_of_time/3600#hour
m=(rest_of_time%3600)/60#minute
s=rest_of_time%60#second
printf("%02d:%02d:%02d\n",h,m,s)
#3???????????¢??????
rest_of_time=(record_time-t)*3
h=rest_of_time/3600#hour
m=(rest_of_time%3600)/60#minute
s=rest_of_time%60#second
printf("%02d:%02d:%02d\n",h,m,s)
end
|
[["-", 8, 736, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 8, 736, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 8, 736, 0, 662, 12, 738, 31, 739, 0, 24], ["-", 8, 736, 0, 662, 12, 738, 12, 738, 17, 85], ["+", 8, 736, 0, 662, 12, 738, 31, 739, 0, 25], ["+", 196, 737, 8, 736, 0, 662, 12, 738, 17, 48]]
| 4
| 145
| 8
|
MAX = 120 * 60
def print_remaining_time(diff)
min, ans_second = diff.divmod(60)
ans_hour, ans_minite = min.divmod(60)
printf "%02d:%02d:%02d\n", ans_hour, ans_minite, ans_second
end
readlines.each do |line|
t, h, s = line.chomp.split.map(&:to_i)
break if t == -1 && h == -1 && s == -1
second = t * 60 * 60 + h * 60 + s
print_remaining_time(MAX - second)
print_remaining_time(MAX - second / 3)
end
|
MAX = 120 * 60
def print_remaining_time(diff)
min, ans_second = diff.divmod(60)
ans_hour, ans_minite = min.divmod(60)
printf "%02d:%02d:%02d\n", ans_hour, ans_minite, ans_second
end
readlines.each do |line|
t, h, s = line.chomp.split.map(&:to_i)
break if t == -1 && h == -1 && s == -1
second = t * 60 * 60 + h * 60 + s
print_remaining_time(MAX - second)
print_remaining_time((MAX - second) * 3)
end
|
[["+", 0, 652, 3, 4, 0, 738, 31, 739, 0, 24], ["-", 0, 652, 3, 4, 0, 738, 12, 738, 17, 85], ["+", 0, 652, 3, 4, 0, 738, 31, 739, 0, 25], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 17, 48]]
| 4
| 110
| 4
|
def zan(total, flag):
rest = 7200 - total if flag else 7200 - total // 3
t, rest = divmod(rest, 3600)
h, s = divmod(rest, 60)
print("{0:02d}:{1:02d}:{2:02d}".format(t, h, s))
while True:
T, H, S = map(int, input().split())
if T == -1:
break
total = T * 3600 + H * 60 + S
for i in [1, 0]:
zan(total, i)
|
def zan(total, flag):
rest = 7200 - total if flag else (7200 - total) * 3
t, rest = divmod(rest, 3600)
h, s = divmod(rest, 60)
print("{0:02d}:{1:02d}:{2:02d}".format(t, h, s))
while True:
T, H, S = map(int, input().split())
if T == -1:
break
total = T * 3600 + H * 60 + S
for i in [1, 0]:
zan(total, i)
|
[["+", 0, 662, 12, 41, 0, 657, 31, 23, 0, 24], ["-", 0, 662, 12, 41, 0, 657, 12, 657, 17, 676], ["+", 0, 662, 12, 41, 0, 657, 31, 23, 0, 25], ["+", 0, 1, 0, 662, 12, 41, 0, 657, 17, 48]]
| 5
| 110
| 4
|
while True:
t, h, s = map(int, input().split())
if t == -1:
break
rest = []
rest.append(7200 - (3600*t + 60*h + s))
rest.append(rest[0]*3)
for r in rest:
t = 0
h = 0
s = 0
if r >= 3600:
t = r//3600
r -= 3600*t
if r >= 60:
h = r//60
r -= 60*h
print("{0:02d}:{1:02d}:{2:02d}".format(t, h, s))
|
while True:
t, h, s = map(int, input().split())
if t == -1:
break
rest = []
rest.append(7200 - (3600*t + 60*h + s))
rest.append(rest[0]*3)
for r in rest:
t = 0
h = 0
if r >= 3600:
t = r//3600
r -= 3600*t
if r >= 60:
h = r//60
r -= 60*h
print("{0:02d}:{1:02d}:{2:02d}".format(t, h, r))
|
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
| 5
| 120
| 5
|
p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')
for e in iter(input,'-1'):
h,m,s=map(int,e.split())
d=7200-h*3600-m*60-s
p(d);p(d*3)
|
p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')
for e in iter(input,'-1 -1 -1'):
h,m,s=map(int,e.split())
d=7200-h*3600-m*60-s
p(d);p(d*3)
|
[["-", 0, 7, 12, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 7, 12, 652, 3, 4, 0, 557, 0, 6]]
| 5
| 87
| 2
|
#!/usr/bin/python
# coding: utf-8
while True:
h, m, s = list(map(int, input().split()))
if h == m == s == -1:
break
full = 2 * 3600
rest = full - (h * 3600 + m * 60 + s)
h = int(rest / 3600)
m = int((rest - h * 3600) / 60)
s = rest - h * 3600 - m * 60
th = int(rest / 1200)
tm = int((rest - th * 1200) / 20)
ts = rest - th * 1200 - tm * 20
print("{:02d}:{:02d}:{:02d}".format(h, m, s))
print("{:02d}:{:02d}:{:02d}".format(th, tm, ts))
|
#!/usr/bin/python
# coding: utf-8
while True:
h, m, s = list(map(int, input().split()))
if h == m == s == -1:
break
full = 2 * 3600
rest = full - (h * 3600 + m * 60 + s)
h = int(rest / 3600)
m = int((rest - h * 3600) / 60)
s = rest - h * 3600 - m * 60
th = int(rest / 1200)
tm = int((rest - th * 1200) / 20)
ts = (rest - th * 1200 - tm * 20) * 3
print("{:02d}:{:02d}:{:02d}".format(h, m, s))
print("{:02d}:{:02d}:{:02d}".format(th, tm, ts))
|
[["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
| 5
| 153
| 4
|
def f(t):
c,t=t%N,t/N
print("%02d:%02d:%02d"%(t/N,t%N,c))
return
while True:
h,m,s=list(map(int,input().split()))
if [h,m,s]==[-1,-1,-1]: break
t=7200-(h*N+m)*N-s
f(t)
f(t*3)
|
N=60
def f(t):
c,t=t%N,t/N
print("%02d:%02d:%02d"%(t/N,t%N,c))
return
while True:
h,m,s=list(map(int,input().split()))
if [h,m,s]==[-1,-1,-1]: break
t=7200-(h*N+m)*N-s
f(t)
f(t*3)
|
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
| 5
| 106
| 3
|
while (!feof(STDIN)) {
$stdin = trim(fgets(STDIN));
$values = explode(',', $stdin);
if (count($values) != 3) {
} else {
list($no, $weight, $height) = $values;
$bmi = $weight / pow($height, 2);
if ($bmi >= 25) {
echo $no . "\n";
}
}
}
|
<?php
while (!feof(STDIN)) {
$stdin = trim(fgets(STDIN));
$values = explode(',', $stdin);
if (count($values) != 3) {
} else {
list($no, $weight, $height) = $values;
$bmi = $weight / pow($height, 2);
if ($bmi >= 25) {
echo $no . "\n";
}
}
}
|
[["+", 36, 36, 36, 36, 36, 36, 0, 493, 0, 605]]
| 6
| 95
| 1
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
String str = sc.next();
String[] a = str.split(",", 0);
double[] b = new double[3];
for (int i = 0; i < 3; i++)
b[i] = Double.parseDouble(a[i]);
if (b[1] / (b[2] * b[2]) >= 25)
System.out.println((int)b[0]);
}
}
}
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str = sc.next();
String[] a = str.split(",", 0);
double[] b = new double[3];
for (int i = 0; i < 3; i++)
b[i] = Double.parseDouble(a[i]);
if (b[1] / (b[2] * b[2]) >= 25)
System.out.println((int)b[0]);
}
}
}
|
[["-", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22]]
| 3
| 145
| 2
|
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String[] nico = sc.nextLine().split(",");
double w = Double.parseDouble(nico[1]);
double h = Double.parseDouble(nico[2]);
if (w / h * h >= 25.0)
System.out.println(nico[0]);
}
}
}
|
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) { new Main(); }
public Main() {
sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String[] nico = sc.nextLine().split(",");
double w = Double.parseDouble(nico[1]);
double h = Double.parseDouble(nico[2]);
if ((w / (h * h)) >= 25.0)
System.out.println(nico[0]);
}
}
}
|
[["+", 0, 57, 15, 15, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 57, 15, 15, 0, 16, 31, 23, 0, 25]]
| 3
| 132
| 4
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* BMI
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while ((line = br.readLine()) != null && !line.isEmpty()) {
StringTokenizer st = new StringTokenizer(line, ",");
String i = st.nextToken();
int w = (int)(Double.parseDouble(st.nextToken()) * 10000);
int h = (int)(Double.parseDouble(st.nextToken()) * 100);
if (w / h * h >= 25) {
System.out.println(i);
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* BMI
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while ((line = br.readLine()) != null && !line.isEmpty()) {
StringTokenizer st = new StringTokenizer(line, ",");
String i = st.nextToken();
int w = (int)(Double.parseDouble(st.nextToken()) * 10000);
int h = (int)(Double.parseDouble(st.nextToken()) * 100);
if (w / (h * h) >= 25) {
System.out.println(i);
}
}
}
}
|
[["+", 15, 15, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 15, 15, 0, 16, 31, 16, 12, 23, 0, 25]]
| 3
| 177
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String[] s = in.nextLine().split(",");
String num = s[0];
double w = Double.parseDouble(s[1]);
double h = Double.parseDouble(s[1]);
if (25 <= w / (h * h)) {
System.out.println(num);
}
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String[] s = in.nextLine().split(",");
String num = s[0];
double w = Double.parseDouble(s[1]);
double h = Double.parseDouble(s[2]);
if (25 <= w / (h * h)) {
System.out.println(num);
}
}
}
}
|
[["-", 49, 200, 51, 492, 3, 4, 0, 504, 71, 499], ["+", 49, 200, 51, 492, 3, 4, 0, 504, 71, 499]]
| 3
| 120
| 2
|
#include <stdio.h>
int main(void) {
float BMI[100], weight[100], height[100];
int Num[100];
int i = 0, count = 0;
while (scanf("%d,%f,%f", &Num[i], &weight[i], &height[i]) != EOF) {
i++;
count++;
}
for (i = 0; i < count; i++) {
BMI[i] = weight[i] / (height[i] * height[i]);
}
for (i = 0; i < count; i++) {
if (BMI[i] > 25.00)
printf("%\nd", Num[i]);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
float BMI[100], weight[100], height[100];
int Num[100];
int i = 0, count = 0;
while (scanf("%d,%f,%f", &Num[i], &weight[i], &height[i]) != EOF) {
i++;
count++;
}
for (i = 0; i < count; i++) {
BMI[i] = weight[i] / (height[i] * height[i]);
}
for (i = 0; i < count; i++) {
if (BMI[i] >= 25.00)
printf("%d\n", Num[i]);
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 155
| 5
|
#include <stdio.h>
int main() {
int n;
double w;
double h;
while (scanf("%d,%lf,%lf", &n, &w, &h) != EOF) {
double bmi;
bmi = w / (h * h);
if (bmi >= 25) {
printf("%d", n);
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int n;
double w;
double h;
while (scanf("%d,%lf,%lf", &n, &w, &h) != EOF) {
double bmi;
bmi = w / (h * h);
if (bmi >= 25) {
printf("%d\n", n);
}
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 72
| 1
|
#include <stdio.h>
int main() {
int n, num[100], i = 0, j;
double w, h, bmi;
for (j = 0; j < 100; j++)
num[j] = 0;
while (scanf("%d,%lf,%lf", &n, &w, &h) != EOF) {
bmi = h * h;
bmi = w / bmi;
if (bmi >= 25) {
num[i] = n;
i++;
}
// }
for (j = 0; j < i; j++)
printf("%d\n", num[j]);
}
return 0;
}
|
#include <stdio.h>
int main() {
int n, num[100], i = 0, j;
double w, h, bmi;
for (j = 0; j < 100; j++)
num[j] = 0;
while (scanf("%d,%lf,%lf", &n, &w, &h) != EOF) {
bmi = h * h;
bmi = w / bmi;
if (bmi >= 25) {
num[i] = n;
i++;
}
}
for (j = 0; j < i; j++)
printf("%d\n", num[j]);
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 0
| 131
| 2
|
#include <stdio.h>
int main(void) {
int number[100];
double weight[100], height[100];
double bmi[100];
int i;
i = 0;
while (scanf("%d", &number[i]) != EOF) {
scanf("%lf %lf", &weight[i], &height[i]);
bmi[i] = weight[i] / height[i] / height[i];
if (bmi[i] >= 25) {
printf("%d\n", number[i]);
}
i++;
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int number[100];
double weight[100], height[100];
double bmi[100];
int i;
i = 0;
while (scanf("%d,", &number[i]) != EOF) {
scanf("%lf,%lf", &weight[i], &height[i]);
bmi[i] = weight[i] / height[i] / height[i];
if (bmi[i] >= 25) {
printf("%d\n", number[i]);
}
i++;
}
return 0;
}
|
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 127
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.