prompt string | response string |
|---|---|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.*;
import java.io.*;
import java.math.*;
public class A{
static int n; static char a[][];
static int cr[],cl[];
static long h;
static void MainMethod()throws Exception{
n=Integer.parseInt(reader.readNextLine());
a=new char[n][]; int i,j;
for (i=0;i<n;i++){
a[i]=reader.readNextLine().toC... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class _0308FarRelativesBirthdayCake {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
int total=0;
char[][] arr = new char[n][n];
for(int i=0;i<n;i++) {
int in=0;
String temp=sc.nextLine();
fo... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
char s[110];
int f[110];
int main() {
int n, r = 0;
scanf("%d ", &n);
for (int i = 0; i < n; i++) {
scanf("%s ", s);
int c = 0;
for (int i = 0; i < n; i++)
if (s[i] == 'C') {
f[i]++;
c++;
}
r += ((c * (c - 1)) / 2);
}
fo... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.*;
import java.util.StringTokenizer;
public class main {
public static void main(String args[]) throws Exception {
FastScanner7 in = new FastScanner7();
int n = in.nextInt();
PrintWriter out = new PrintWriter(System.out);
int[]height=new int[n];
int[]widht=new ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int n;
char v[101][101];
int oo;
int ro;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> v[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (v[i][j] == 'C') {
ro++... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
in >> a.first >> a.second;
return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
out <<... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int n, i, j, sum, a[110][110];
char x;
int main() {
cin >> n;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++) {
cin >> x;
if (x == 'C') {
a[0][j]++;
a[i][0]++;
}
}
for (i = 1; i <= n; i++) {
sum = sum + a[0][i] * (a[0][i... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def count(matrix):
global l
for i in range(len(matrix)):
sum=0
for j in range(len(matrix)):
if(matrix[j][i]=="C"):
sum+=1
l.append(sum)
n=int(input())
l=[]
inp=[]
for i in range(n):
a=input().strip()
inp.append(a)
x=a.count("C")
l.append(x)
cou... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def cal(n):
if n==0 or n==1:
return 0
else:
return (n*(n-1))/2
n=int(raw_input())
a=[]
for i in range(n):
s=raw_input()
a.append(s)
c=0
for i in a:
s=0
for j in i:
if j=='C':
s+=1
c+=cal(s)
for i in range(n):
s=0
for j in range(n):
if a[j][... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
long long int a[1000000], b[1000000];
int main() {
long long int i, n, m, k, l = 1, j, x, y, p, sum = 0;
float r;
string s[100000];
cin >> n;
for (i = 0; i < n; i++) cin >> s[i];
for (i = 0; i < n; i++) {
x = 0;
for (j = 0; j < n; j++) {
if (s[i][j... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
m = []
for _ in range(n):
m.append(input())
ans = 0
# row
for i in range(n):
cnt = m[i].count('C')
ans += cnt * (cnt - 1) // 2
# col
for i in range(n):
cnt = [row[i] for row in m].count('C')
ans += cnt * (cnt - 1) // 2
print(ans) |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | z=[];s=0;k=0
for _ in " "*int(input()):
k=input();a=k.count("C")
for i in range(len(k)):
if k[i]=="C":z=z+[i]
s=s+(a*(a-1))//2
for i in range(len(k)):a=z.count(i);s+=(a*(a-1))//2
print(s)
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Arrays;
import java.util.Scanner;
/**
* Created by user on 20.02.2016.
*/
public class A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
String[] str = new String[n];
int ans = 0;
for (int i =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class birthdayscake {
static int rowColumn(char[][] str){
int column=0;
int row =0;
for(int i=0;i<str.length;i++){
int rcount=0;
int ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
mat = []
count = 0
for i in range(n):
mat.append(input())
for i in range(n):
c = 0
for j in range(n):
if (mat[i][j] == "C"):
c += 1
if (c > 1):
count += (c * (c - 1)) // 2
for i in range(n):
c = 0
for j in range(n):
if (mat[j... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
/**
* Created by yuu on 5/4/17.
*/
public class Problem629A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String[] rows = new String[n];
int total = 0;
for (int i = 0; i < n; i++) {
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | readInts=lambda: list(map(int, input().split()))
n = int(input())
g = []
for i in range(n):
g+=[input()]
ret = 0
for i in range(n):
cnt = g[i].count('C')
ret += cnt*(cnt-1)//2
for j in range(n):
cnt = 0
for i in range(n):
cnt += g[i][j] == 'C'
ret += cnt*(cnt-1)//2
print(ret)
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
int main() {
int n;
scanf("%d", &n);
char array[101][101];
int i, j;
int count;
int sum = 0;
for (i = 0; i < n; i++) {
scanf("%s", array[i]);
}
for (i = 0; i < n; i++) {
count = 0;
for (j = 0; j < n; j++) {
if (array[i][j] == 'C') {
count++;
}
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... |
import java.util.Scanner;
public class Div2_343_A {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
String[] arr = new String[n];
int[] rows = new int[n];
int[] cols = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = scan.next();
rows[i]... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
a = []
q = 0
q1 = 0
c = 0
c1 = 0
for i in range(n):
a.append(list(input()))
for i in range(n):
q = 0
for j in range(n):
if a[i][j] == 'C':
q+=1
c = c+(q*(q-1))//2
for j in range(n):
q1 = 0
for i in range(n):
if a[i][j] == 'C':
q1+... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class CP {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char[][] c = new char[n][n];
for(int i = 0; i < n; i++) {
char[] row = sc.next().toCharArray();
c[i] = row;
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
unsigned long long comb(unsigned long long n) {
if (n < 2) {
return 0;
}
return n * (n - 1) / 2;
}
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<vector<char>> v;
for (int i = 0; i < n; i++) {
vector<char> vi;
for (int j = 0; j... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
size_t solve(const std::vector<std::string>& c) {
const size_t n = c.size();
size_t count = 0;
for (size_t i = 0; i < n; ++i) {
for (size_t j = 0; j < n; ++j) {
for (size_t k = j + 1; k < n; ++k) {
if (c[i][j] == 'C' && c[i][k] == 'C') ++count;
if (c[j][i] == 'C'... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
public class Solutions {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
int res = 0;
int[] columns = new int[100];
Arrays.fill(columns, 0)... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const int mod = 1e9 + 7;
int comb(int n, int k) {
int place = 1;
int k_fact = 1;
for (int i = 0; i < k; i++) {
place *= (n - i);
k_fact *= i + 1;
}
return place / k_fact;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.*;
import java.util.*;
public class C2 {
public static void main(String args[])throws IOException
{
Scanner input = new Scanner(System.in);
int n = input.nextInt();
char m[][] = new char[n][n];
int ris = 0;
for(int j = 0; j < n; j ++)
{
String row = input.next();
for(int x =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class Birtday{
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long happiness = 0;
int[] colCount = new int[n];
scan.nextLine();
for(int i=0;i<n;i++){
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
s = [ input() for i in range(n)]
f = lambda x: x * (x - 1) // 2
ans = 0
for i in range(n):
cnt1 = s[i].count('C')
cnt2 = sum(s[j][i] == 'C' for j in range(n))
if cnt1 > 1:
ans += f(cnt1)
if cnt2 > 1:
ans += f(cnt2)
print(ans) |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int A[105][105];
int main() {
int n;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
for (int j = 0; j < n; j++) {
if (s[j] == 'C') {
A[i][j] = 1;
} else {
A[i][j] = 0;
}
}
}
for (int i =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import math
n = int(input())
def nCr(n, r):
f=math.factorial
return int(f(n) / (f(r) * f(n - r)))
cake=[]
for i in range(n):
cake.append(input())
happiness=0
for row in cake:
choclates = row.count('C')
if choclates >= 2:
happiness += nCr(choclates, 2)
for row in zip(*cake):
choclates ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum = 0;
cin >> n;
char ch[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cin >> ch[i][j];
}
for (int i = 0; i < n; i++) {
int c = 0;
for (int j = 0; j < n; j++) {
if (ch[i][j] == 'C') c++;
}
sum = ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
long long ans = 0;
char grid[200][200] = {};
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
scanf("%s", grid[i]);
}
for (int i = 0; i < n; i++) {
long long res = 0;
long long res2 = 0;
for (int j = 0; j < n; j++) {
if (grid[i][j]... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char **s;
s = new char *[n];
int countDub = 0, countC = 0;
for (int i = 0; i < n; i++) {
s[i] = new char[n];
for (int j = 0; j < n; j++) cin >> s[i][j];
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) {
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
int main(void) {
long int N, i, j, *row, *col;
char c;
scanf("%ld\n", &N);
row = (long int*)malloc(sizeof(long int) * N);
col = (long int*)malloc(sizeof(long int) * N);
for (i = 0; i < N; i++) {
row[i] = 0;
col[i] = 0;
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def twoCx(x):
x = int(x)
if x < 2:
return 0
return int(x * (x - 1) / 2)
n = int(input())
cakes = []
res = 0
for i in range (n):
count = 0
row = list(input())
cakes.append(row)
for j in range (n):
if row[j] == 'C':
count += 1
res += twoCx(count)
for j in range ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def ni():
return int(raw_input())
def si():
return raw_input()
def pairs(x):
return (x * (x - 1)) / 2
n = ni()
a = []
ans = 0
cols = [0] * n
for _ in range(n):
s = si()
row = 0
for i in range(n):
c = s[i]
if c == 'C':
row += 1
cols[i] += 1
ans += ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int i, n, j, v1[107], v2[107];
long long ans = 0;
char c;
int main() {
cin >> n;
for (i = 1; i <= n; ++i)
for (j = 1; j <= n; ++j) {
cin >> c;
if (c == 'C') {
v1[i]++;
v2[j]++;
}
}
for (i = 1; i <= n; ++i) ans += 1LL * v1[i] *... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | from math import factorial as f
n=int(input())
a=[]
ans=0
for i in range(n):
a.append(input())
k=0
for j in a[i]:
if j=='C':
k+=1
if k>1:
ans+=f(k)//(2*f(k-2))
for i in range(n):
k=0
for j in range(n):
if a[j][i]=='C':
k+=1
if k>1:
ans+... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #!/usr/bin/env python
import math
n = int(input())
l = []
for i in range(n):
l.append(input())
answer = 0
for s in l:
chocolate = 0
for c in s:
if c == 'C':
chocolate += 1
try:
answer += int(math.factorial(chocolate) / math.factorial(chocolate - 2)) / 2
except ValueError:... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
a = []
res = 0
for i in range(n):
a += [input()]
for i in range(n):
x = 0
y = 0
for j in range(n):
if a[i][j] == 'C':
x += 1
if a[j][i] == 'C':
y += 1
res += x * (x-1) // 2 + y * (y-1) // 2
print(res)
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | side=int(input())
row=[0]*side; col=[0]*side
#Counts for 'C' in row and col
for i in range(side):
s=input()
for j in range(side):
if s[j]=='C':
row[i]+=1; col[j]+=1
happy=0
#Counts happiness
for i in range(side):
if row[i]>=2:
for j in range(row[i]-1, 0, -1):
happy+=j
if col[i]>=2:
for j in range(col[i... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import math
fact = math.factorial
n = int(raw_input())
c = []
for i in range(n):
r = []
for j in raw_input():
r.append(j)
c.append(r)
ans = 0
for i in range(n):
t = 0
for j in range(n):
if c[i][j] == 'C':
t += 1
if t >= 2:
ans += fact(t)/(fact(2)*fact(t-... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, result = 0, sum;
char s;
vector<vector<char>> a;
cin >> n;
for (int i = 0; i < n; i++) {
a.push_back(vector<char>());
for (int j = 0; j < n; j++) {
cin >> s;
a[i].push_back(s);
}
}
for (int i = 0; i < n; i++) {
s... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class Main629A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n = in.nextInt();
long ans = 0;
int[] columns = new int[n];
for (int i = 0; i < n; i++) {
String line = in.next();
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 4;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
string s[n];
int ct = 0;
for (int i = 0; i < n; i++) {
cin >> s[i];
int cnt = 0;
for (int j = 0; j < n; j++) {
if (s[i][j] == 'C') {
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = (int)(input())
a = ["" for i in range(n) ]
for i in range(n):
a[i]=(input())
m=0
for i in range(n):
for j in range(n):
for k in range(j):
if(a[i][j]==a[i][k]=='C'):
m=m+1
for i in range(n):
for j in range(n):
for k in range(j):
if(a[k][i]==a[j][i]=... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Created by Administrator on 05.03.2016.
*/
public class TaskA {
StringTokenizer st;
PrintWriter out;
BufferedReader in;
public static void ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int c[1000], r[1000], n, x;
string s;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
for (int j = 0; j < n; j++)
if (s[j] == 'C') {
x += c[i] + r[j];
c[i]++;
r[j]++;
}
}
cout << x;
}
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int n, ans, b[105], c[105];
char a[105][105];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
if (a[i][j] == 'C') {
b[i]++;
c[j]++;
}
}
}
for (int i = 1; i <= n; i+... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char cad[1 << 7][1 << 7];
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%s", cad[i]);
int ans = 0;
int s;
for (int i = 0; i < n; i++) {
s = 0;
for (int j = 0; j < n; j++)
if (cad[i][j] == 'C') s++;
ans += s * (s - 1)... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | i = input()
a = []
s = 0
k = 0
for x in range(i):
a.append([])
y = list(str(l) for l in raw_input())
for p in range(i):
a[x].append(y[p])
for x in a:
if x.count('C') > 1:
for h in range(1, x.count('C')):
s+=h
for m in range(i):
for n in range(i):
if a[n][m] == 'C'... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
char a;
vector<char> v;
vector<vector<char>> vv;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a;
v.push_back(a);
}
vv.push_back(v);
v.... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... |
import java.util.Scanner;
public class Cake {
public static int[] getArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = sr.nextInt();
}
return array;
}
public static int[][] getMatrix(int sizeI, int sizeJ) {
int[][] array = new int[sizeI][sizeJ];
for (int i ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, x[101] = {0}, y[101] = {0}, a[101][101], k = 0;
char s;
cin >> n;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) {
cin >> s;
if (s == '.')
a[i][j] = 0;
else
a[i][j] = 1;
}
for (i = 0; i < n; i++)... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | /**
* Created by Omar on 2/20/2016.
*/
import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int n=Integer.pa... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
scan.nextLine();
int[] strCount = new int[n];
int[] colCount = new int[n];
for(int i = 0; i < n; i++) {
String str = scan.nextLine();
for(int j = 0; j <... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | from itertools import product
def main():
n = int(raw_input())
mat = [raw_input().strip() for _ in xrange(n)]
arr = []
for x, y in product(xrange(n), xrange(n)):
if mat[x][y] == 'C':
arr.append((x, y))
count = 0
for x in xrange(len(arr)):
for y in xrange(len(arr)):
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
deque<int> v;
int t, n, m, i, j, ans, k, a, b, c, d, e, f, sz, q, x;
string s, s2, s3, s4, s5, s6;
int ar[(int)(1e5 + 10)], ar2[(int)(1e5 + 10)];
void brainfuck();
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
brainfuck();
return 0;
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
long long int fact(long long int n) {
long long int ans = 1;
for (long long int i = 1; i <= n; i++) {
ans *= i;
}
return ans;
}
long sum(long long ara[], long n) {
double sum = 0;
for (int i = 0; i < n; i++) {
sum += ara[i];
}
return sum;
}
int main(... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long int sum = 0;
cin >> n;
char ara[n][n + 1];
for (int i = 0; i < n; i++) cin >> ara[i];
for (int i = 0; i < n; i++) {
int ans = 0;
for (int j = 0; j < n; j++) {
if (ara[i][j] == 'C') ans++;
}
sum = sum + ans * (a... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
string second[105];
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> second[i];
long long ans = 0;
for (int i = 0; i < n; i++) {
long long k = 0;
for (int j = 0; j < n; j++) k += (second[i][j] == 'C');
if... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
c = [[*input()] for _ in range(n)]
ans = 0
for i in c:
t = i.count('C')
ans += (t * (t - 1)) // 2
for i in [*zip(*c)]:
t = i.count('C')
ans += (t * (t - 1)) // 2
print(ans) |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.io.*;
public class FarRelativesBirthdayCake{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
int length = Integer.parseInt(input);
int[] rows = new int[len... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
char a[105][105];
int n, c, cnt;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
if (a[i][j] == 'C') {
c++;
}
}
cnt += c * (c ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, ans = 0;
char cake[110][110];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s", cake[i]);
}
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 0; j < n; j++) {
if (cake[i][j] == 'C') {
cnt++;
}
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
int main() {
int i, j, n, r = 0, c = 0, ans = 0;
char str[107][107];
scanf("%d", &n);
for (i = 0; i < n; ++i) {
scanf("%s", str[i]);
r = 0;
for (j = 0; j < n; ++j) {
if (str[i][j] == 'C') {
++r;
}
}
ans += (r * (r - 1)) / 2;
}
for (j = 0; j < ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
int main() {
int n1, n2 = 0, n3 = 0;
std::cin >> n1;
std::vector<std::vector<char>> v1(n1, std::vector<char>(n1));
for (int i = 0; i < n1; i++)
for (int j = 0; j < n1; j++) std::cin >> v1[i][j];
for (int i = 0; i < n1; i++) {
for (int j = 0; j < n1; j++) {
if (v1[i][j] =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | from math import *
from sys import *
n=int(input())
mat=[]
for i in range(n):
cur=input()
app=[]
for i in cur:
if i=="C":
app.append(1)
else:
app.append(0)
mat.append(app[:])
res=0
for i in range(n):
q=sum(mat[i])
qq=sum([mat[j][i] for j in range(n)])
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
cake = []
t = 0
for i in range(n):
cake.append(list(input()))
x = cake[-1].count("C")
t += ((x * (x - 1)//2))
for i in zip(*cake):
x =list(i).count("C")
t += ((x * (x - 1)//2))
print(t)
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #map(int,raw_input().split())
import itertools
n = int(raw_input())
def fact(n): return n*fact(n-1) if n > 0 else 1
def c(n,r): return fact(n)/(fact(r)*(fact(n-r))) if n >=r else 0
p = []
for _ in xrange(n):
p.append(raw_input())
ans = 0
for i in p: ans += c(i.count('C'),2)
for j in zip(*p): ans += c(j.count(... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = input()
A=map(lambda x: raw_input(), xrange(n))
rowcount=[ len([i for i in a if i=='C']) for a in A ]
columncount=[0 for i in xrange(n)]
for j in xrange(n):
tempcolumncount=0
for i in xrange(n):
if A[i][j]=='C':
tempcolumncount+=1
columncount[j]=tempcolumncount
def paircount(x):
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n=int(raw_input())
mat=[]
for i in range(0,n):
mat.append(str(raw_input()))
ans=0
for i in range(0,n):
cnt=0
for ii in range(0,n):
if mat[i][ii]=='C':
cnt+=1
ans+=(cnt*(cnt-1))/2
for i in range(0,n):
cnt=0
for ii in range(0,n):
if mat[ii][i]=='C':
cnt+=1
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
long long fun(int n) {
long long ans = 1;
ans = (n * (n - 1)) / 2;
return ans;
}
int main() {
int n;
cin >> n;
char ch;
int row[n];
int col[n];
for (int i = 0; i < n; i++) {
row[i] = 0;
col[i] = 0;
}
for (int i = 0; i < n; i++)
for (int j =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char **a = new char *[n];
for (int i = 0; i < n; i++) a[i] = new char[n];
int i, j;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++) cin >> a[i][j];
int rezult = 0, c1 = 0;
int c12 = 0;
for (i = 0; i < n; i++) {
int kol... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def fact(n):
s = 1
for i in range(1,n+1):
s*=i
return s
def C(n, r):
res = fact(n)/(fact(r)*fact(n-r))
return res
n=int(input())
res=[[0 for i in range(n)] for _ in range(2)]
r = 0
for i in range(n):
row = str(input())
for j in range(n):
if row[j] == 'C':
res[0... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n = int(input())
M = []
for i in range(n):
M += [input()]
ans = 0
for i in range(n):
c, r = 0, 0
for j in range(n):
if M[i][j] == 'C':
c += 1
if M[j][i] == 'C':
r += 1
if c > 1:
ans += c * (c - 1) // 2
if r > 1:
ans += r * (r - 1) // 2
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def C2( x ):
if x <= 1:
return 0
return x*(x-1)//2
if __name__ == "__main__":
n = int( input() )
cake = []
for i in range(n):
cake.append( [c for c in input()] )
#for line in cake:
# print(line)
res = 0
for i in range(n):
num = 0
for j in range... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def factorial(n):
if n == 1:
return 1
if n == 0:
return 1
return n * factorial(n - 1)
def cnk(n, k):
if k > n:
return 0
return factorial(n)/(factorial(n - k) * factorial(k))
def main():
result = 0
n = int(input())
data = list()
new_data = list()
for i ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
char a[maxn][maxn];
int main() {
ios::sync_with_stdio(false);
int n;
int cnt = 0;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
char c;
cin >> c;
a[i][j] = c;
}
}
for (int i = 0; i < n; i... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.*;
import java.lang.*;
public class BirthdayCake{
public static void main(String arr[]){
Scanner sc = new Scanner(System.in);
int p = sc.nextInt();
String a[] = new String[p];
for(int i=0;i<p;i++){
a[i]=sc.next();
}
int count_row[] = new int[p];
int count_col[] = new int[p]; ... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import math
n = int(input())
a = [[c=='C' for c in input()] for i in range(n)]
b = [sum(a[i]) for i in range(n)]
c = [sum(a[i][j] for i in range(n)) for j in range(n)]
print(sum((k*(k-1)//2) for k in b)+sum((k*(k-1)//2) for k in c))
|
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string cake[n];
int row[n], column[n];
memset(row, 0, sizeof(row));
memset(column, 0, sizeof(column));
for (int i = 0; i < n; i++) {
cin >> cake[i];
for (int j = 0; j < cake[i].length(); j++) {
if (cake[i][j] == 'C')... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def nCr(n, r):
return (fact(n) / (fact(r)
* fact(n - r)))
def fact(n):
res = 1
for i in range(2, n+1):
res = res * i
return res
dict = {}
n = int(input())
li = []
res = 0
y = n
for x in range(n):
dict[x] = 0
while n > 0:
li.append(input())
n -= 1
k =... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int ans, n;
vector<pair<int, int> > a;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
char c;
cin >> c;
if (c == 'C') a.push_back(make_pair(i, j));
}
for... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class CF_629A {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long ans = 0;
int[] columns = new int[n];
for(int i=0;i<n;i++) {
String line = scan.next();
int row = 0;
for(int j=0;j<columns.length;j++) {
i... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | def combin2(n):
"""Nombre de combinaisons de n objets pris k a k"""
x = 1
y = 1
i = n - 1
while i <= n:
x = (x * i) // y
y += 1
i += 1
return x
def main():
n = int(input())
cake = []
happiness = 0
for _ in range(n):
s = input()
cake += [... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.util.Scanner;
public class A {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n=Integer.parseInt(sc.nextLine());
char move[][]=new char[n][n];
int countx[]=new int[n];
int ans=0;
for(int i=0;i<n;i++)
{
String inp... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
template <typename T>
bool domax(T &a, T b) {
return (b > a ? (a = b, true) : false);
}
template <typename T>
bool domin(T &a, T b) {
return (b < a ? (a = b, true) : false);
}
int N, ans;
char s[105][105];
int f(int i) { return i * (i - 1) / 2; }
int main() {
scanf("%d", &N);
for (int i... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... |
import java.io.*;
import java.util.*;
public class Solve{
static final int MOD=1000000007;
public static void main (String[] args) throws Exception{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.o... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
int main() {
char str[101][101];
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> str[i][j];
}
}
int c = 0, sum = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (str[i][j] == 'C') {
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import sys
def i(): return sys.stdin.readline().strip()
sys.setrecursionlimit(99999999)
ii=lambda:map(int,i().split(" "))
n=int(i())
cake=[i() for e in xrange(n)]
acc=0
for e in xrange(n):
h,v=0,0
for ee in xrange(n):
if cake[e][ee]=="C":
h+=1
if cake[ee][e]=="C":
v+=1
... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | n=int(input());a=[0]*n;b=[0]*n;ans=0
for i in range(n):
s=input()
for j in range(n):
if s[j]=='C':a[i]+=1;b[j]+=1
for i in range(n):ans+=a[i]*(a[i]-1)//2
for i in range(n):ans+=b[i]*(b[i]-1)//2
print(ans) |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... |
import java.io.*;
import java.util.StringTokenizer;
/**
* Created by seal on 2/28/2016.
*/
public class Main {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
TaskA solver = new TaskA();
solver... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
static Scanner in = new Scanner(System.in);
static int num[];
static int map[][];
static int n;
public static void main(String[] args)
{
num = new int[101];
map = new int[101]... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... |
import java.util.Scanner;
public class Main {
public static void main(String arg[]) {
Scanner input = new Scanner(System.in);
int line = input.nextInt();
char[][] matrix = new char[line][line];
for(int i = 0 ; i < line ; i++) {
String s = input.next();
for (... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
bool equalTo(double a, double b) {
if (fabs(a - b) <= 1e-9) return true;
return false;
}
bool notEqual(double a, double b) {
if (fabs(a - b) > 1e-9) return true;
return false;
}
bool lessThan(double a, double b) {
if (a + 1e-9 < b) return true;
return false;
}
b... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int MAXI = 0x7fffffff;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char dz[] = "SENW";
struct debugger {
template <typename T>
d... |
Problem: Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly ... | #include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, c, cont;
char p;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
long long col[n], fil[n];
for (i = 0; i < n; i++) {
col[i] = 0;
fil[i] = 0;
}
for (i = 0; i < n; i++) {
for (j = 0; j <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.