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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; char ar[102][102], c; cin >> n; int i, j, k; long long an = 0, ans = 0; for (i = 0; i < n; i++) { an = 0; for (j = 0; j < n; j++) { cin >> c; ar[i][j] = c; if (c == 'C') an++; } ans += an * (an - 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 countchochor(a,k): count = 0 for i in range(len(a)): if Cake[k][i] == 'C': count += 1 return count*(count-1)//2 def countchocver(a,k): count = 0 for i in range(len(a)): if Cake[i][k] == 'C': count += 1 return count*(count-1)//2 def total(a): total ...
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() ans = 0 l = [] for i in range(n): temp = [] l.append(temp) for i in range(n) : a = raw_input() if a.count('C') > 0: ans += a.count('C')*(a.count('C')-1)/2 for i in range(n): l[i].append(a[i]) for i in range(n): if l[i].count('C') > 0: ans += l[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=[] ans=0 for _ in range(n): line=input() s.append(line) m=line.count('C') ans+=m*(m-1)//2 for i in range(n): m=0 for j in range(n): if s[j][i]=='C': m+=1 ans+=m*(m-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 ...
n = input() matrix = [] result = 0 for i in xrange(n): matrix.append(list(raw_input())) tmp = matrix[i].count('C') result += (tmp*(tmp-1))/2 for i in xrange(n): count = 0 for j in xrange(n): if (matrix[j][i] == 'C'): count += 1 result += (count*(count-1))/2 print result
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 n = int(sys.stdin.readline()) C = [sys.stdin.readline().strip() for _ in xrange(n)] R = 0 for i in xrange(n): r = 0 for j in xrange(n): r += C[i][j] == 'C' R += r*(r-1)/2 for i in xrange(n): r = 0 for j in xrange(n): r += C[j][i] == 'C' R += r*(r-1)/2 print R
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 Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); solve(in, out); out.close(); } ...
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, i, j, s, sum = 0; cin >> n; char a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[i][j]; } for (i = 0; i < n; i++) { s = 0; for (j = 0; j < n; j++) { if (a[i][j] == 'C') s++; } if (s == 2) su...
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 input = sys.stdin.readline ''' ''' n = int(input()) row, col = [0] * n, [0] * n for r in range(n): s = input().rstrip() for c, v in enumerate(s): if v == "C": row[r] += 1 col[c] += 1 res = 0 for i in range(n): if row[i] > 1: res += row[i] * (row[i]-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 ...
from sys import stdin ##################################################################### def iinput(): return int(stdin.readline()) def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split())) ###################################################################...
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, totale = 0, c[101], r[101]; string s[100]; cin >> n; for (int i = 0; i < n; i++) { c[i] = 0; r[i] = 0; } for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<string> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int res = 0; for (int i = 0; i < n; ++i) { int cnt = 0; for (int j = 0; j < n; ++j) { if (a[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 ...
import java.util.Arrays; import java.util.Scanner; public class problemA { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String[] a = new String[n]; in.nextLine(); for (int i = 0; i < n; i++) a[i] = in.nextLi...
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 cake { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n= in.nextInt(); char a[][]= new char[n][n]; int res =0; for(int i=0;i<n;i++) { String x = in.next(); a[i] = x.toCharArray(); } 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.io.*; public final class CF { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[][] s = new char[n][n]; for(int i = 0; i<n; i++) s[i] = sc.next().toCharArray(); long ans = 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.util.Scanner; public class A { public void solve() { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); char[][] cells = new char[n][n]; int[] row = new int[n]; int[] col = new int[n]; for(int i = 0;i < n;i++) { cells[i] = cin.next().toCharArray(); } 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 ...
var readInt = () => parseInt(readline()) var readIntArray = () => readline().split(' ').forEach(item => parseInt(item)) var fact = n => n > 0 ? n*fact(n-1) : 1; var N = readInt() var cake = [] for (var i = 0; i < N; i++) { cake.push(readline()) } var ans = 0 cake.forEach(function(s,i) { var n = Array.prototyp...
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 Solution { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int side = sc.nextInt(); String[] str = new String[side]; for( int i=0; i < side; i++){ str[i] = sc.next(); } int result = 0; int 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 ...
#include <bits/stdc++.h> using namespace std; unsigned long long combination(unsigned long long n, unsigned long long k) { int ans = 1; while (k > 0) { ans *= n; n--; k--; } return ans / 2; } int main() { unsigned long long n; cin >> n; char arr[1000][1000]; for (int i = 0; i < n; i++) f...
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.InputStreamReader; import java.util.Scanner; public class DoorCake { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); int n= Integer.parseInt(br.readLine()); char[][] cak...
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.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class A implements Closeable { private InputReader in = new In...
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 _Solution { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void solve() throws IOException { int t = 1; while ...
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()) x = [] for i in range(n): x.append([j=='C' for j in input()]) print(sum([sum(range(1, sum(i))) for i in x]) + sum([sum(range(1, i)) for i in map(sum, zip(*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(input()) rows = [] for i in range(n): rows.append(input()) pairs = 0 for i in range(n): c = len([ch for ch in rows[i] if ch == 'C']) pairs += c * (c - 1) // 2 for i in range(n): c = 0 for j in range(n): if rows[j][i] == 'C': c += 1 pairs += c * (c - 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 ...
import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = Integer.parseInt(input.nextLine()); char[][] ch = new char[x][x]; String s; int 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.*; public class A{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); int numRows = sc.nextInt(); int[] rows = new int[numRows]; int[] cols = new int[numRows]; int numPairs = 0; for (int i = 0; i < numRows; i++) { String str = sc.next(); for (int k = 0; 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 ...
n=input() a=[] ans=0 for i in range(n): a.append(list(raw_input())) for i in range(n): x=0 for j in range(n): if a[i][j]=='C': x+=1 ans+=x*(x-1)/2 for i in range(n): x=0 for j in range(n): if a[j][i]=='C': x+=1 ans+=x*(x-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.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[][] a = new int [n + 1][n + 1]; int ans = 0; for (int i = 0; i < n; ++i) { String s = input.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 ...
n=int(input()) a=[input() for i in range(n)] # print(a) m=0 for i in range(n): for j in range(n): if a[i][j]=='C': l=i+1 while l<n: if a[l][j]=='C': m+=1 l+=1 k=j+1 while k<n: if a[i][k]=='C': m+=1 k+=1 print(m)
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 ...
a=int(input()) c=[] d=[] k=0 l=0 for i in range(a): c.append(input()) if (c[i]).count('C')>1: d.append(c[i]) for j in range(a): if d[0][l]=='C': d[0]=d[0][:l]+d[0][l+1:] k+=d[0].count('C') else: l+=1 l=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 double PI = acos(-1.0); int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } long long fact(int n) { if (n == 0) return 1; return n * fact(n - 1); } string con(int x) { stringstream stringstream; stringstream << x; string y;...
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() res = [] for _ in range(n): res.append(raw_input()) seen_row = [0] * n seen_column = [0] * n for r in range(len(res)): row = res[r] for c in range(len(row)): cell = row[c] if cell == 'C': seen_row[r] += 1 seen_column[c] += 1 happy = 0 for i 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 ...
#include <bits/stdc++.h> using namespace std; long long a[100001]; int main() { long long n, s = 0, i, k, j; string m; cin >> n; for (i = 1; i <= n; i++) { cin >> m; k = 0; for (j = 0; j < n; j++) if (m[j] == 'C') k++, a[j + 1]++; s += ((k - 1) * k) / 2; } for (i = 1; 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; while (cin >> n) { string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } long long cnt1 = 0, cnt2 = 0, ans = 0; for (int i = 0; i < n; 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 ...
#include <bits/stdc++.h> using namespace std; long long int fact(long long int a) { if (a <= 1) return 1; return a * fact(a - 1); } int main() { long long int n, m, i, x, k, ans = 0, y; char a; int r[110] = {0}, c[110] = {0}; cin >> n; for (x = 1; x <= n; x++) { for (y = 1; y <= n; y++) { cin >>...
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 for i in range(n): a[i] = input().strip() ans = 0 for i in range(n): s = 0 for j in range(n): if a[i][j]=='C': s+=1 # print(a[i][j]) ans += s*(s-1)//2 for i in range(n): s = 0 for j in range(n): if a[j][i]=='C': 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 ...
n = int(input()) res = 0 row = [0 for i in range(n)] col = [0 for i in range(n)] a = [list(input()) for i in range(n)] for i in range(n): for j in range(n): if a[i][j] == "C": row[i] += 1 col[j] += 1 for i in range(n): res += max(0, (row[i])*(row[i]-1)//2) res += max(0, (col[i])*(col[i]-1)//2) pr...
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()) list = ["" for i in range(n)] for i in range(n): list[i] = input() sum = 0 for c in list: f = 0 for i in range(n): if c[i] == "C": f += 1 sum = sum + f * (f - 1) / 2 for i in range(n): f = 0 for j in range(n): if list[j][i] == "C": f += 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; const int MAX = 1e2 + 2; int N; char grid[MAX][MAX]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%s", grid[i]); long long ans = 0; for (int r = 0; r < N; r++) for (int c = 0; c < N; c++) { if (grid[r][c] == 'C') for (int 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, w = 0; cin >> n; char tab[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> tab[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (tab[i][j] == 'C') { for (int k = j + 1; k < n; 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 ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Iterator; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamW...
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 ...
cc = [] result = 0 for i in range(int(input(""))): cc.append(list(input(""))) def getpairs(pairs): return ((pairs*(pairs-1))/2) #count rows def getcol(colnum): temp = [] for i in range(len(cc)): temp.append(cc[i][colnum]) return temp for i in range(len(cc)): result = result+getpairs...
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 Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = Integer.parseInt(scanner.next()); char[][] input = new char[n][n]; int[] rowCounter = new int[n]; int[] colCounter = new int[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()); L = []; c = 0 for i in range(n): L.append(input()) def f(x): return x*(x-1)//2 for i in range(n): c += (f(L[i].count('C')) + f([L[x][i] for x in range(n)].count('C'))) print(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; const int MAX = 100; int col[MAX], row[MAX], n, sum; 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') { sum += col[i] + row[j], col[i]++, row[j]++; } } } cout << 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ProblemA { BufferedReader rd; ProblemA() throws IOException { rd = new BufferedReader(new InputStreamReader(System.in)); compute(); } private void compute() throws IOException { ...
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 main(): n, res = int(input()), 0 l = [input() for _ in range(n)] for src in l, zip(*l): for s in src: c = s.count("C") res += c * (c - 1) // 2 print(res) if __name__ == '__main__': 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 ...
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); char[][] cake=new char[n][n]; int[] row=new int[n]; int[] col=new int[n]; for(int i=0;i<n;i++) { cak...
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() rows = [] cnt = 0 for _ in xrange(n): row = raw_input() v = row.count('C') cnt += (v*(v-1))/2 rows.append(row) for i in xrange(n): v = 0 for j in xrange(n): if rows[j][i] == 'C': v += 1 cnt += (v*(v-1))/2 print 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> using namespace std; int main(int argc, char **argv) { int n, RES = 0; cin >> n; vector<vector<char> > A(n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { char tmp; cin >> tmp; A[i].push_back(tmp); } for (int i = 0; i < n; i++) { int k = 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 ...
//package codeforce; import java.util.Scanner; /* @author Kbk*/ public class FarsRelativesBirthdayCake { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int array[][]=new int[N][N]; for(int i=0;i<N;i++){ String str=sc.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; int row[105], col[105]; char a; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int count = 0; for (int j = 0; j < n; j++) { cin >> a; if (a == 'C') { count += 1; col[j] += 1; } } row[i] = count; } 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 ...
t=int(input()) l=[] for i in range(t): l.append(input()) row=0 for i in range(t): a=l[i].count("C") row=row+(a*(a-1))//2 col=0 for i in range(t): con=0 for j in range(t): if l[j][i]=="C": con=con+1 col=col+(con*(con-1))//2 print(row+col)
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 sumation(num): total = 0 for i in range(num): total += i return total dimention = int(input()) rows = [] columns = [] count = 0 for i in range(dimention): rows.append(list(input())) columns.append([]) for i in range(dimention): for e in range(len(rows[i])): columns[e].append(rows[i][e]) for i in 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 ...
n = int(input()) a = 0 x = [] for i in range(n): x.append(list(input())) s = x[i].count('C') a += s * (s - 1) for i in range(n): counter = 0 for t in range(n): if x[t][i] == 'C': counter += 1 a += counter * (counter - 1) print(a // 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 ...
a=int(input()) table=[] for i in range(a): table.append(input()) result=0 for i in range(a): result+=(table[i].count('C')*(table[i].count('C')-1))//2 for i in range(a): qwe=0 for j in range(a): if table[j][i]=='C': qwe+=1 result+=(qwe*(qwe-1))//2 print(result) # Wed Jul 29 2020 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 nC2(int n) { return n * (n - 1) / 2; } int main() { int n; cin >> n; string s; vector<long long> row(n), column(n); for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < s.size(); j++) { if (s[j] == 'C') { row[i]++; co...
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, m, tong, dem, min1, kq, dai; int d[1111111], h[111], c[111]; char s[111][111]; long long max1; long long gt(int z) { if (z == 1) return 1; return z * gt(z - 1); } void sss(int sc) { int x, y; x = sc - 2; if (x == 0) x = 1; max1 += gt(sc) / (2 * gt(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 a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); int[] rows = new int[n]; int[] cols = new int[n]; int total = 0; for (int i = 0; i < n; i++) { String line = sc.nextLine(); for (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 ...
#include <bits/stdc++.h> using namespace std; char mat[110][110]; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int ans = 0, mc, i, j; for (i = 0; i < n; i++) { cin >> s; for (j = 0; j < n; j++) mat[i][j] = s.at(j); } for (i = 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 ...
n = int( raw_input() ) MAXN = 100 row = [0]*MAXN col = [0]*MAXN for i in range( 0, n ): x = raw_input() for j in range( 0, n ): if x[j] == 'C': row[i] += 1 col[j] += 1 ans = 0 for i in range( 0, n ): ans += row[i] * ( row[i]-1 ) / 2 ans += col[i] * ( col[i]-1 ) / 2 print "%d" % (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 ...
n = int(input()) a = [] t = 0 for i in range(n): a.append(list(input())) x = a[-1].count('C') t +=((x*(x-1)//2)) for i in zip(*a): 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 ...
from collections import defaultdict import math n=int(input()) Row=defaultdict(int) Column=defaultdict(int) for i in range(n): x=list(input()) Row[i]=x.count('C') for index in range(0,len(x)): if x[index]=='C': Column[index]+=1 fact=0 for i in Row.keys(): fact+=(int(math.factorial(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; const int N = 0; int n, k, x, t, m; string s; vector<int> v; int row[100], col[100]; int main() { cin >> n; memset(row, 0, sizeof row); memset(col, 0, sizeof col); for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < n; j++) { if (s[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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.InputMismatchException; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { QuickScanner sc = new QuickScanner(); int 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 ...
import java.util.*; import java.math.*; public class Coinge{ public static void solution(char[][] arr,int t) { int count = 0; // int coount = 0; int m1 = 0; for(int i=0;i<t;i++) { for(int j=0;j<t;j++) { if(arr[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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<vector<char>> v(n, vector<char>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> v[i][j]; } } long long cnt = 0; 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.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author student */ public class Codeforces { 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 ...
# coding=utf-8 if __name__ == '__main__': n = int(input()) face = list() for i in range(n): line = str(input()) line = line.replace('.', '0') line = line.replace('C', '1') line = [int(it) for it in line] face.append(list(line)) tar = 0 for i in range(n): line_c = list() line_r = list() for j in ra...
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.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solution implements Runnable { BufferedReader in; PrintWriter out; StringTokeniz...
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=[];col=[] for i in range(n) : s=list(input()) a.append(s) cnt=0 import math for i in range(len(a)) : z=a[i].count("C") if z>2 : cnt+=(math.factorial(z)//(math.factorial(z-2)*2)) elif z==2 : cnt+=1 for i in range(len(a)) : c=0 for j in range(len(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 ...
def solution(l1,n): i=0 pairs=0 while i<len(l1): j=0 count=0 while j<len(l1[i]): if l1[i][j]=="C": count+=1 j+=1 pairs+=int(count*(count-1)/2) i+=1 i=0 while i<len(l1): j=0 count=0 while j<len(l1...
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 = 110; int n, ans; char a[N][N]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", &a[i]); for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) cnt += a[i][j] == 'C'; ans += cnt * (cnt - 1) / 2; } 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); Str...
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> char map[105][105]; int row[105], col[105]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char ch; scanf(" %c", &ch); if (ch == 'C') { row[i]++; col[j]++; } } } 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 ...
'''input 4 CC.. C..C .CC. .CC. ''' n = input() rows = [0] * n cols = [0] * n for i in xrange(n): s = raw_input() for j, k in enumerate(s): if k == 'C': rows[i] += 1 cols[j] += 1 res = 0 for i in cols + rows: if i > 1: res += i * (i - 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 ...
n=int(input()) l=[] s=0 for i in range (n): a=input() l.append(a) s1=a.count("C") s=s+(s1*(s1-1))//2 for i in range(n): s1=0 for j in range(n): if l[j][i]=="C": s1=s1+1 s=s+(s1*(s1-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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char A[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> A[i][j]; } long long ans = 0; for (int i = 0; i < n; i++) { long long val = 0; for (int j = 0; j < n; j++) if (A[i][j] == 'C') val++;...
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 ...
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package codeforces; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.Bi...
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()) matrix = [] for _ in range(n): matrix.append([i for i in input()]) # print(*matrix) level_of_happiness = 0 for row in matrix: quantity = row.count('C') level_of_happiness += (quantity - 1) * (quantity / 2) # print(level_of_happiness) for column in range(n): amount_of_chocolate = 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; string s[111]; int a[111], b[111]; int main(void) { std::ios::sync_with_stdio(false); cin.tie(0); int i, j, n; int re = 0; int t; cin >> n; for (i = 0; i < n; i++) cin >> s[i]; for (i = 0; i < n; i++) { t = 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 ...
#include <bits/stdc++.h> using namespace std; long long d[10000], e[10000]; int main() { string k, p; long long a, b, c = 0, f = 0, g, h, i, j, l, m, n, o, q, r, s, t, u, v, w, x, y, z; cin >> a; for (i = 0; i < a; i++) { cin >> k; for (j = 0; j < a; j++) { if (k[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 ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); int n; cin >> n; vector<string> arr; for (int i = 0; i < n; i++) { string x; cin >> x; arr.push_back(x); } int chocolate = 0; for (int i = 0; i < n; i++) { 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 ...
from collections import defaultdict import math x=int(input()) ans=0 mat=[] for _ in range(x): a=input() mat.append(a) temp=0 for i in a: if(i=='C'): temp+=1 ans+=(temp*(temp-1))//2 for i in range(x): temp=0 for j in range(x): if(mat[j][i]=='C'): temp+...
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 col[110]; int row[110]; char o[110]; int main() { int i, j, n; int ans = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", o); for (j = 0; j < n; j++) { if (o[j] == 'C') { col[i]++; row[j]++; } } } for (i = 0; i < n; i++) { 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 ...
def countc(m): count=0 for i in range(len(m)): if m[i]=='C': count+=1 return count/2 def ncr(count): if count<=0: return 0 return count*(count-1)/2 n=int(input()) total=0 happy=0 row=[] col=[] for j in range(n): y=input() row.append(y) total+=countc(row[j]) happy+=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 ...
import java.util.Scanner; /** * Created by vaishalibehl on 2/21/16. */ public class Main { public static void main(String[] args){ Scanner s = new Scanner(System.in); int n = Integer.parseInt(s.nextLine().split(" ")[0]); String [][] array = new String[n][n]; 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 ...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, i, j; cin >> n; char c[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> c[i][j]; } } long long res = 0, tar = 0; 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 ...
from math import factorial n = int(input()) a = [input() for x in range(n)] ans = 0 for i in range(n): p = k = 0 for j in range(n): if a[i][j] == 'C': k += 1 if a[j][i] == 'C': p += 1 if k > 1: ans += factorial(k) / (2 * factorial(k - 2)) if p > 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; const int MAXN = 1005; const int INF = 0x3f3f3f3f; char str[110]; int row[110], cul[110]; int main() { int n; cin >> n; memset(row, 0, sizeof(row)); memset(cul, 0, sizeof(cul)); for (int i = 0; i < n; i++) { cin >> str; 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 ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; vector<string> arr(n); for (int i = 0; i < n; ++i) cin >> arr[i]; int sum = 0; for (string s : arr) { int a = count((s).begin(), (s).end(), 'C'); sum += a * (a - 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 ...
//package Codeforces; /** * @copyright ankurverma1994 */ import java.io.*; import java.util.*; public class ProbA { final int mod = (int) 1e9 + 7; final double eps = 1e-6; final double pi = Math.PI; //------------> Solution starts here!! @SuppressWarnings("Main Logic") void solve() { ...
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 Main { static int count=0; static int n; static char[][] arr; static boolean[][] vis; static int floor=0; public static void main(String[] args) { Scanner s1 = new Scanner(System.in); n = s1.nextInt(); boolean flag = false; arr = new char[n][n]; vis = new boolean[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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; vector<vector<int> > a(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char z; cin >> z; if (z == 'C') { a[i][j] = 1; } } } 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(raw_input()) data = [] row = [0 for _ in xrange(n)] col = [0 for _ in xrange(n)] for i in xrange(n): s = raw_input() for j, val in enumerate(s): row[j] += (val == 'C') col[i] += (val == 'C') ans = 0 def f(n): return (n*(n-1))/2 for i in xrange(n): ans += ( f(row[i]) + f(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 ...
t = int(input()) l=[] for _ in range(t): #l.append(input()) h = input() h = list(h) l.append(h) #print(l) g = len(l[0]) count=0 for i in range(t): c=0 a=1 for j in range(g): if l[i][j]=='C': c+=1 count += (c*(c-1))//2 #count+=a for i in range(t): c=0 a=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 ...
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class A { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static boolean debug = false; static void solve() { int n = in.nextInt(); char[][] t = new cha...
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 f[120][120]; int main() { cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> f[i][j]; int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) if (f[i][j] == 'C') cnt++; if (cnt > 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 ...
def happy(): n = int(input()) cake = [input() for i in range(n)] w = 0 for y in range(n): c = cake[y].count('C') w += int(c * (c - 1) / 2) for x in range(n): c = 0 for y in range(n): if cake[y][x] == 'C': c += 1 w += int(c * (c - 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 ...
from sys import stdin n=int(stdin.readline()) cake=[] for i in range(n): cake.append(str(stdin.readline())) res=0; for i in range(n): cnt=0 for j in range(n): if cake[i][j]=='C': cnt+=1 res+=((cnt)*(cnt-1)/2) for i in range(n): cnt=0 for j in range(n): if cake[j][i]==...