prompt string | response string |
|---|---|
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.util.*;
import java.io.*;
public class B {
FastScanner in;
PrintWriter out;
int[] a;
int[][] mem;
int sol(int l, int r) {
if (l > r) return 1;
if (l == r) return 1;
if (mem[l][r] != -1) return mem[l][r];
if (a[l] == a[r]) {
mem[l][r] = sol(l... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const long long oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
long long a[510];
long long dp[510][510];
long long rec(long long i, long long j) {
if (i == j) return 0;
if (dp[i][j] != -1) return dp[i][j];
long long res = rec(i + 1, j) + 1;
for (long long k = (i ... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const int N = 505;
int n, a[N], dp[N][N];
int main() {
memset(dp, 0x3f, sizeof(dp));
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) dp[i][i] = 1;
for (int i = 1; i <= n - 1; i++) {
if (a[i] == a[i + 1])
dp[... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.*;
public class B {
static final int INF = Integer.MAX_VALUE / 3;
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
void solve() throws IOException {
int n = nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 510;
const int INF = 1e9 + 7;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar()... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const int INFINITE = (int)(0xffffffff >> 2);
int n;
int gs[600];
int dp[600][600];
int run(int l, int r) {
if (l > r) return 0;
if (l == r) return 1;
if (dp[l][r] != INFINITE) {
return dp[l][r];
}
dp[l][r] = min(dp[l][r], run(l + 1, r) + 1);
for (int k = l +... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
impo... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
const long long inf = 998244353;
vector<int> adj[200010], vis(200010, 0), par(200010, 0), dis(200010, 0),
di(200010, 0)... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | # Legends Always Come Up with Solution
# Author: Manvir Singh
import os
import sys
from io import BytesIO, IOBase
def main():
n=int(input())
a=list(map(int,input().split()))
dp=[[0]*n for _ in range(n)]
for i in range(n):
dp[i][i]=1
for i in range(n-1,-1,-1):
for j in range(i+1,n,1)... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.*;
public class B607 {
public static void main(String[] args) throws IOException {
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = input.nextInt();
as = new int[n];
for(int i = 0; i<n; i++) as[i] = input.nextInt();
memo = new int[n][n];
for(int[] A... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | from math import inf
n=int(input())
s=[int(X) for X in input().split()]
dp=[[inf for i in range(n)] for j in range(n)]
isdp=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
isdp[i][i]=1
for i in range(1,n):
for j in range(n):
if i+j>=n:
break
if s[j]==s[i+j]:
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
long long dp[505][505];
long long a[505];
long long solve(long long i, long long j) {
if (i > j) return 0;
if (i == j) return 1;
if (j - i == 1) {
if (a[i] == a[j]) return 1;
return 2;
}
if (dp[i][j] != -1) return dp[i][j];
long long ans = 1 + solve(i, j... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.StringTokenizer;
public class Codeforces {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Solution solution = new Solution();
solution.solve(in, out);
out... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | dp = [[-1 for i in range(505)] for j in range(505)]
n = int(input())
A = [int(i) for i in input().split()]
def do(i, j):
#print('At',i , j)
if i>=j:
dp[i][j] = 1
return 1
if dp[i][j] != -1:
return dp[i][j]
ans = len(A)
if A[i] == A[j]:
ans = min(ans, do(i+1... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.StringTokenizer;
public class Codeforces {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Solution solution = new Solution();
solution.solve(in, out);
out... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.util.*;
import java.io.*;
import java.math.BigInteger;
/**
*
* @author usquare
*/
public class ProblemB{
static long mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
static int n;
static int maxn = 1000;
static int[] arr;
static int[][] dp;
stati... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> v;
int dp[500][500];
int solve(int x, int y) {
if (x > y) return 0;
if (x == y) return 1;
if (x + 1 == y) {
return (v[x] == v[y] ? 1 : 2);
}
int &val = dp[x][y];
if (val != -1) return val;
int ans = y - x + 1;
ans = min(... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int ma... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Cf607B {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.*;
public class B {
FastScanner in;
PrintWriter out;
void solve() {
int n = in.nextInt();
int[] c = new int[n];
for (int i = 0; i < n; i++) {
c[i] = in.nextInt();
}
int[][] dp = new int[n][n];
for (int l = 0; l < n; l++) {
for (int r = 0; r < n; r++) {
if (r... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
int main() {
int dp[1000][1000], n, a[10000];
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int j = 1; j <= n; j++)
for (int i = 1; i <= j; i++) {
dp[i][j] = dp[i][j - 1] + 1;
for (int k = i; k < j; k++)
if (a[k] == a[j])
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
long long n;
long long col[1003];
long long memo[1003][1003];
long long solve(long long left, long long right) {
if (left >= right) return 1;
if (memo[left][right] != -1) return memo[left][right];
long long ans = 100000000000000;
if (col[left] == col[right]) ans = m... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
int a[505];
int dp[505][505];
int f(int i, int j) {
if (j < i) return 0;
if (i == j) return 1;
if (dp[i][j] != -1) return dp[i][j];
int mi = 10000;
if (a[i] == a[i + 1]) mi = min(mi, 1 + f(i + 2, j));
mi = min(mi, 1 + f(i + 1, j));
for (int k = i + 2; k <= j; ... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const int n = 600;
int N;
int arr[n];
int dp[n][n];
int go(int L, int R) {
if (L > R) return 0;
if (dp[L][R] != -1) return dp[L][R];
int ret = N + 1;
if (arr[L] == arr[R]) ret = go(L + 1, R - 1);
for (int lr = L + 1; lr <= R; lr++) {
ret = min(ret, go(L, lr - ... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
public class Main {
static int [][] dp;
static i... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.util.Scanner;
public class Main {
final static int infinity = 0x3f3f3f3f;
static int[][] f = new int[512][512];
static int[] a = new int[510];
static int DP(int l, int r) {
if(l==r) return 1;
if(l>r) return 0;
if(f[l][r] != infinity) return f[l][r];
f[l][r]= Math.min(f[l][r], DP(l + 1, r)... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
/**
* @author Mubtasim Shahriar
*/
public class Zuma {
public static void main(String[] args) {
InputStream inputStream = System.in;
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | # Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
def main():
n=int(input())
arr=list(map(int,input().split()))
dp=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
dp[i][i]=1
for dff in range(2,n+1):
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
int c[500 + 10];
int f[500 + 10][500 + 10];
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
for (int len = 1; len <= n; ++len)
for (int l = 1, r = len; r <= n; ++l, ++r) {
if (len == 1)
f[l][r] = 1;
else {
... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
long long n;
long long c[600];
long long dp[600][600];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> c[i];
dp[i][i] = 1;
}
for (long long i = 2; i <= n; i++) {
for (... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class P607B {
public static void main(String[] args) throws IOException {
final BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
int n = Integer.parseInt(in.re... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new PrintStream(System.out));
int n=Integer.parseInt(f.readLine());... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
const int INFINITE = (int)(0xffffffff >> 2);
int n;
int gs[600];
int dp[600][600];
int run(int l, int r) {
if (l > r) return 0;
if (l == r) return 1;
if (dp[l][r] != INFINITE) {
return dp[l][r];
}
dp[l][r] = min(dp[l][r], run(l + 1, r) + 1);
if (gs[l] == gs[... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | #include <bits/stdc++.h>
using namespace std;
int solve(vector<vector<int> > &ans, const vector<int> &x, int a, int b) {
if (ans[a][b] != -1) {
return ans[a][b];
}
if (a + 1 == b) {
ans[a][b] = 1;
return ans[a][b];
}
if (a == b) {
return 1;
}
int res = x.size();
res = min(res, solve(ans,... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | import java.io.*;
public class Zuma {
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
String arr[]=br.readLine().split(" ");
int dp[][]=new int[n][n];
for(int l=1;l<=n;l++){
for(in... |
Problem: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones... | # Legends Always Come Up with Solution
# Author: Manvir Singh
import os
import sys
from io import BytesIO, IOBase
def check(a,x,y):
mid=(y-x+1)//2
for i in range(mid):
if a[x+i]!=a[y-i]:
return 0
return 1
def main():
n=int(input())
a=list(map(int,input().split()))
dp=[[0]*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 ... | //package HackerEarthA;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.text.*;
import java.math.*;
import java.util.regex.*;
/**
*
* @author prabhat
*/
public class easy18{
public static long[] BIT;
public static long[] tree;
public static long[] sum;
public sta... |
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 fac(n):
S=1
for i in range(1,n+1):
S=S*i
return(S)
def comb(n,p):
return int((fac(n)/(fac(p)*fac(n-p))))
n=int(input())
d=[]
somme=0
for i in range(n):
ch=input()
d.append(ch)
S=0
for j in range(len(ch)):
if ch[j]=="C":
S=S+1
somme=somme+comb(S,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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
string a;
int str[n], stl[n], s = 0;
char c;
for (int i = 0; i < n; i++) {
str[i] = 0;
stl[i] = 0;
}
getline(cin, a);
for (int i = 0; i < n; i++) {
getline(cin, a);
for (int j = 0; j < n; j++) {
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 ... |
import java.util.Scanner;
/**
* http://codeforces.com/contest/629/problem/A?locale=en
*/
public class A {
public static void main(String[] args) {
new A().doJob();
}
private void doJob() {
try (Scanner scanner = new Scanner(System.in)) {
int n = scanner.nextInt();
int[] rowCnt = new int[n];
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;
public class FarRelativesBirthdayCake {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
input.nextLine();
boolean [] [] arr = new boolean [n] [n];
for(int i=0;i<n;i++) {
String s = input.nextLine();
for(int j=0;j<s.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 ... | from itertools import chain
count_pairs = lambda n: n * (n - 1) // 2
cake = [input() for _ in range(int(input()))]
print(sum(count_pairs(line.count('C')) for line in chain(cake, zip(*cake))))
# Made By Mostafa_Khaled |
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 R343qA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt();
char s[][] = new char[n][n];
for(int i = 0; i < n; i++)
s[i] = in.readString().toCharA... |
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;import math;k=0
for _ in " "*int(input()):
k=input();a=[]
for i in range(len(k)):
if k[i]=="C":a=a+[i];z=z+[i]
s=s+((math.factorial(len(a)))//(math.factorial(abs(len(a)-2))*2))
for i in range(len(k)):s=s+(math.factorial(z.count(i))//(math.factorial(abs(z.count(i)-2))*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.io.*;
import java.util.*;
public class CF343Aver2
{
FastScanner in;
PrintWriter out;
int i = 0, j = 0;
void solve()
{
/**************START**************/
int n = in.nextInt();
int[] rows = new int[n];
int[] cols = new int[n];
for (i = 0; i < 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 ... | x = int(input())
rc = 0
cc = []
ccs = 0
pairs = 0
v = 0
for i in range(x):
cc.append(0)
for i in range(x):
y = input()
ya = []
for w in range(x):
ya.append(y[w])
for f in range(x):
if ya[f] == "C":
rc += 1
cc[f] += 1
if rc == 2:
pairs += 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.Scanner;
public class problem1 {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
char[][] cake=new char[n][n];
for(int i=0;i<n;i++)
{
cake[i]=sc.next().toCharArray();
}
int ans=0,cnt;
for(int i=0;i<n;i++)
{
cnt=0;
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;
int main() {
int n;
cin >> n;
char a[n][n];
int i, i2;
for (i = 0; i < n; i++) {
for (i2 = 0; i2 < n; i2++) {
cin >> a[i][i2];
}
}
int i4;
int result = 0;
for (i = 0; i < n; i++) {
for (i2 = 0; i2 < n; i2++) {
if (a[i][i2] == '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>
long long int fact(long long int x) {
if (x == 0)
return 1;
else
return x * fact(x - 1);
}
long long int create(int n) {
int i, j, r, x;
long long int c;
char A[n][n];
x = fact(2);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
scanf(" %c", &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 math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in 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(0);
cin.tie(0);
cout.tie(0);
int a, i, j, countr, cr = 1, cm = 1, countm, tot = 0;
cin >> a;
char mat[a][a];
for (i = 0; i < a; i++) {
countr = 0;
for (j = 0; j < a; j++) {
cin >> mat[i][j];
if (mat[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 ... | #343A
n = int(raw_input())
arr = []
for i in range(0,n):
arr_in = list(raw_input())
arr.append(arr_in)
c_count = 0
r_count = 0
happiness = 0
for j in range(0, n):
for k in range(0, n):
if arr[k][j] == "C":
r_count+=1
if arr[j][k] == "C":
c_count+=1
happiness += 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 ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
n = int(input())
a = [ 0 for i in range(n) ]
ans = 0
for i in range(n):
str = input()
m = 0
for j in range(n):
if str[j] == 'C':
m += 1
a[j] += 1
ans += m*(m-1)
start = time.time()
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;
int main() {
int n, count;
long long unsigned int sum = 0;
cin >> n;
char cake[n][n];
for (int i = 0; i < n; i++) {
count = 0;
for (int j = 0; j < n; j++) {
cin >> cake[i][j];
if (cake[i][j] == 'C') count++;
}
if (count > 1) {
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;
template <class first, class second>
void maximize(first& x, const second& y) {
if (x < y) x = y;
}
template <class first, class second>
void minimize(first& x, const second& y) {
if (x > y) x = y;
}
int n;
string a[123];
int main() {
cin >> n;
for (int 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 ... | p=lambda x:x*(x-1)//2
n=int(input())
a=[input() for _ in[0]*n]
r=sum(p(x.count('C')) for x in a)
a=[[a[j][i] for j in range(n)] for i in range(n)]
r+=sum(p(x.count('C')) for x in a)
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.util.Arrays;
import java.util.Scanner;
public class FarRelativesBirthdayCake {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
String[] arrCake = new String[n];
for (int i = 0; i < n; i++) arrCake[i] = scanner... |
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 = []
h = 0
for i in range(n):
b = [1 if i == "C" else 0 for i in input()]
a.append(b)
for i in range(n):
for j in range(n):
if a[i][j] == 1:
for k in range(i):
if a[k][j]==1:
h+=1
for m in range(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 ... | ###################################
## Eric Breno B. - UFCG - BRAZIL ##
###################################
n = int(raw_input())
matriz = []
def qtd(n):
if n < 2: return 0
if n == 2: return 1
return n-1 + qtd(n-1)
for i in xrange(n):
en = raw_input()
matriz.append(en)
choc = 0
lin = 0
col = 0
for i in xra... |
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;
#pragma comment(linker, "/STACK:100000000")
int ri() {
int x;
scanf("%d", &x);
return x;
}
string matrix[111];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
cin >> matrix[i];
}
int res = 0;
for (int i = 0; i < n; i++) {
int 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 ... | n=int(raw_input())
a=[]
b=[]
add=0
for i in range(n):
a=list(raw_input())
b.append(a)
for i in range(n):
c=0
c=b[i].count('C')
add+=c*(c-1)/2
for i in range(n):
d=0
for j in range(n):
if b[j][i]=='C':
d+=1
add+=d*(d-1)/2
print add |
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
def solve():
n = int(input())
pairs = []
pairs_count = 0
for i in range(n):
input_str = input()
for j in range(n):
if input_str[j] == "C":
pairs.append((i + 1, j + 1))
for i in range(n):
count_r = 0
count_c = 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.io.*;
import java.util.StringTokenizer;
public class Main {
static MyScanner in;
static PrintWriter out;
// static Timer timer = new Timer();
public static void main(String[] args) throws IOException {
in = new MyScanner();
out = new PrintWriter(System.out, true);
... |
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 summ(int x) {
int a = 0;
for (int i = 0; i < x; i++) a += i;
return a;
}
int main() {
int n;
char ch[101][101];
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) cin >> ch[i][j];
int c = 0;
for (int i = 0; i < n; i++) {
int 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 ... | import java.util.*;
public class arr {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n=scn.nextInt();
char[][] arr = new char[n][n];
int[] row = new int[n];
int[] col = ne... |
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>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int NMAX = 100 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const long long INFLL = 100000... |
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 Random {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
String[][] mat = new String[n][n];
int count=0;
int ans=0;
for(int i=0;i<n;i++){
String s=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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
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 FarRelativeBirthdayCake {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.parseInt(scan.nextLine());
int mat[][] = new int[n][n];
for(int i=0; i< n; i++) {
String[] tmp = scan.nextLine().split("");
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 ... | n = int(input())
cake = []
res = 0
for i in range(n):
a = input()
b = a.count("C")
res = res + (b*(b-1)//2)
cake.append(a)
rotated = zip(*cake[::-1])
for i in rotated:
b = i.count("C")
res = res + (b*(b-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 ... | #import sys
#sys.stdin = open("input.in","r")
#sys.stdout = open("test.out","w")
n=int(input())
l=list()
for i in range(n):
l.append(input())
m=a=0
for i in range(n):
for j in l[i]:
if(j=='C'):
a+=1
m+=round(a*(a-1)/2)
a=0
for i in range(n):
for j in range(n):
if(l[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.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math... |
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 = 1 << 21;
int col[maxn], row[maxn];
int main() {
string second;
int n, ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> second;
for (int j = 0; j < n; j++) {
if (second[j] == 'C') ans += col[i] + row[j], col[i]++, row[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;
/**
* @author tainic, 2/20/16
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
char[][] a = new char[n][n];
for (int i = 0; i < n; i++) {
a[i] = in.next().toCharArray();... |
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, math
def rs():
return sys.stdin.readline().strip()
def ri():
return int(sys.stdin.readline().strip())
def ras():
return list(sys.stdin.readline().strip())
def rai():
return map(int,sys.stdin.readline().strip().split())
def raf():
return map(float,sys.stdin.readline().strip().split())
de... |
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 = int(input())
grid = [None] * n
for i in range(n):
grid[i] = input()
print(solver(grid))
def solver(grid):
n = len(grid)
total = 0
for row in range(n):
Cs = grid[row].count('C')
total += nC2(Cs)
for col in range(n):
Cs = 0
for row in range(n):
if grid[row][col] == 'C':
Cs += 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 math import factorial
n = int(input())
matrix_1 = []
matrix_2 = []
for i in range(n):
add = list(input())
matrix_1.append(add)
matrix_2.append(add)
matrix_2 = list(zip(*matrix_2))
ans = 0
for i in range(n):
n_1 = len(list(filter(lambda x: x == "C", matrix_1[i])))
n_2 = len(list(filter(lambda 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 os
import math
import time
n = int(input())
ar = []
for i in range(n):
s = input()
ar.append(s)
flag = False
counter = 0
pr = [0,0,1,3,6]
for i in range(5,101):
pr.append(pr[i-1]+i-1)
for i in range(n):
j = 0
c = 0
while j < n:
if ar[i][j]=='C':
c+=1
j+=1
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.*;
import java.math.BigInteger;
/*
* This file was created by ayush in attempt to solve the problem Far relatives birthday cake on codeforces
*/
public class BirthdayCake {
public BigInteger factorial(int n){
BigInteger ans = new BigInteger("1");
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 ... | import math
n = int(input())
c = [ input() for i in range(n) ]
f = [1]
for i in range(1,n+1):
f.append(f[i-1]*i)
ans = 0
for i in range(n):
k = 0
for j in range(n):
if c[i][j] == 'C': k+=1
if k>1: ans += f[k] / (f[2] * f[k-2])
for j in range(n):
k = 0
for i in range(n):
if c[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 ... | read = lambda: map(int, input().split())
n = int(input())
a = [input() for i in range(n)]
f = lambda x: x * (x - 1) // 2
cnt = 0
for i in range(n):
k1 = a[i].count('C')
k2 = sum(a[j][i] == 'C' for j in range(n))
cnt += f(k1) + f(k2)
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 binomial_coefficient(int n, int k) {
if (n < k) return 0;
int res = 1;
if (k > n - k) k = n - k;
for (int i = 0; i < k; i++) {
res *= n - i;
res /= i + 1;
}
return res;
}
int main() {
int n;
cin >> n;
char s[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>
int main() {
int i, j, n, sum = 0, cnt = 0;
char a[101][101];
scanf("%d ", &n);
for (i = 0; i < n; i++) {
scanf("%s", a[i]);
}
for (i = 0; i < n; i++) {
cnt = 0;
for (j = 0; j < n; j++) {
if (a[i][j] == 'C') cnt++;
}
sum += (cnt * (cnt - 1)) / 2;
}
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 ... | import java.util.*;
public class FarRelativesBirthdayCake {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
int counter = 0;
String[][] list = new String[count][count];
for (int i = 0; i < count; i++) {
String input = sc.next();
for (int j = 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;
int main() {
int n;
char a[200][200];
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) cin >> a[i][j];
int sum = 0;
for (int i = 1; i <= n; i++) {
int s = 0;
for (int j = 1; j <= n; j++)
if (a[i][j] == 'C') s++;
sum += 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 ... | n = int(input())
a = [input() for i in range(n)]
res = 0
for i in range(n):
r = a[i].count('C')
res += r * (r-1) // 2
for i in range(n):
r = 0
for j in range(n):
if a[j][i] == 'C':
r += 1
res += r * (r-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 ... | if __name__ == '__main__':
n = int(raw_input())
cake = [list(raw_input()) for _ in range(n)]
cake = [[{'.': 0, 'C': 1}[square] for square in row] for row in cake]
rows = [sum(row) for row in cake]
cols = [0]*n
for i, row in enumerate(cake):
for j, elem in enumerate(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 cake(lst):
result = 0
for i in range(len(lst)):
for j in range(len(lst)):
for z in range(j):
if lst[i][j] == "C" and lst[i][z] == 'C':
result += 1
if lst[j][i] == "C" and lst[z][i] == "C":
result += 1
return resu... |
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>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
using namespace std;
bool isprime(long long n) {
if (n % 2 == 0) {
return false;
}
for (auto i = 3; i * i <= n; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
long long digitsum(long long 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;
void FastIO() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
FastIO();
long long int n, ans = 0;
char ch;
cin >> n;
vector<long long int> c1(n, 0), c2(n, 0);
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++) {
cin >> s[i];
}
int y = 0;
for (int i = 0; i < n; i++) {
int y2 = 0;
for (int j = 0; j < n; j++) {
if (s[j][i] == 'C') {
y2++;
}
}
y += (y2) * (y2 -... |
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 Fact(int x) {
int fac = 0;
for (int i = 1; i <= x; i++) {
fac += i;
}
return fac;
}
int main() {
int n, c = 0;
char A[100][100];
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) cin >> A[i][j];
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.*;
public class cake{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
char[][] a=new char[n][n];
int[] b=new int[2*n];
long ans=0;
String st=new String();
for (int i=0;i<n;i++) {
st=s.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 ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.valueOf(br.readLine());
String matrix[] = new St... |
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 gcd(long long a, long long b) {
if (!b) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n;
cin >> n;
int 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>
using namespace std;
int main() {
int n;
cin >> n;
char a[105][105];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cin >> a[i][j];
}
int s = 0;
for (int i = 0; i < n; i++) {
int c = 0;
for (int j = 0; j < n; j++) {
if (a[i][j] == 'C') c++;
}
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, m, sum, i, j, ans;
char A[102][102];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%s", A[i]);
}
for (i = 0, ans = 0; i < n; i++) {
for (j = 0, sum = 0; j < n; j++) {
if (A[i][j] == 'C') {
sum++;
}
}
an... |
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())
ans =0
l =[]
for i in range(n):
s= raw_input()
cnt = s.count('C')
l.append(s)
ans = ans + cnt*(cnt-1)/2
for i in range(n):
d=0
for j in range(n):
if l[j][i] == 'C':
d=d+1
ans=ans+ d*(d-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 ... | a = [0] * 100
b = [0] * 100
n = int(input())
for i in range(n):
s = input()
for j in range(n):
if s[j] == 'C':
a[i] += 1
b[j] += 1
ans = 0
for x in a:
ans += x * (x - 1) // 2
for x in b:
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 ... | #include <bits/stdc++.h>
using namespace std;
char arr[102][102];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cin >> arr[i][j];
}
map<int, int> m1, m2;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.