Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cstring> #include <algorithm> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fd(i,a,b) for(int i=a;i>=b;i--) using namespace std; typedef long long ll; const int N=45; int n; char a[N][N]; ll f[N][N][N]; ll solve(int l,int r,int mid) { if (~f[l][r][mid]) return f[l][r][mid]; if (l==r)...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; #define rep(i,s,t) for(int i=s;i<t;i++) typedef long long ll; ll dp[44][44][44],isused[44][44][44];char isok[44][44]; ll solve(int l,int mid,int r) { if(r-l<=0)return 1; if(mid<=l||mid>=r)return 0; if(isused[l][mid][r])return dp[l][mid][r]; isused[l][mid][r]...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
// ※※※ 解答不能 ※※※ // Um_nik氏 // https://atcoder.jp/contests/agc039/submissions/7870163 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 42; bool A[N][N]; ll dp[N][N][N]; int n; char s[N]; int main(){ scanf("%d", &n); n *= 2; for(int i = 0; i < n; i++){ scanf("%s", s);...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <iostream> #include <stdio.h> #include <string.h> #include <map> #include <unordered_map> #include <algorithm> #include <vector> #include <queue> #include <set> #include <math.h> using namespace std; #define x first #define y second #define vi vector<int> #define pb push_back #define mp make_pair #define pii...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t=0; char ch=getchar(); int f=1; while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f; } typedef long long ll; const int maxn=45; int n; char s[maxn]; bool...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define uint unsigned #define pii pair<int,int> #define pll pair<ll,ll> #define PB push_back #define fi first #define se second #define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++) #define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--) #define CLR...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; char str[43][43]; long long ans , dp[43][43][43] , N; long long dfs(int l , int mid , int r){ if(l == r) return 1; if(l == mid || r == mid) return 0; if(dp[l][mid][r] != -1) return dp[l][mid][r]; dp[l][mid][r] = 0; for(int j = l ; j < mid ; ++j) for(int k = mid + 1 ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<cstdio> typedef long long ll; int N; char A[42][42]; ll f[42][42][42],g[42][42][42][42]; int main(){ scanf("%d",&N); for(int i=0;i<N*2;i++)scanf("%s",A[i]); for(int l=N*2;l--;){ for(int m=l+1;m<N*2;m++) for(int r=m+1;r<=N*2;r++){ if(m-l==1||r-m==1)f[l][m][r]=m-l==1&&r-m==1; else for(int i=l+1;i...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define ll long long #define db long double #define mp make_pair #define pb push_back #define all(a) a.begin(), a.end() using namespace std; ll dp[40][40][40][40]; ll forest[40][40][40][40]; int n; void mod(int &a){ a %= (2*n); if (a < 0) a += 2*n; } ll get_f(int a, int b, int c, int d){...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZER...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cstring> #include <cstdlib> #include <cstring> #include <algorithm> #include <numeric> #include <functional> #include <vector> #define LOG(FMT...) fprintf(stderr, FMT) using namespace std; typedef long long ll; const int N = 41; int n; char a[N][N]; ll dp[N][N][N], dp2[N][N][N][N], dp3...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<cstdio> typedef long long ll; char S[45]; ll dp[45][45][45]; int A[45][45], N; int main() { scanf("%d", &N), N <<= 1; for(int i=1;i<=N;i++) { scanf("%s", S + 1); for(int j=1;j<=N;j++) A[i][j] = S[j] - '0'; } for(int i=N;i>=2;i--) { dp[i][i][i] = 1; for(int j=i+2;j<=N;j++) for(int k=i+1;k<=j-1...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<algorithm> #include<chrono> #include<ctime> #include<climits> #include<functional> #include<numeric> #include<iomanip> #include<iostream> #include<map> #include<queue> #include<random> #include<set> #include<stack> #include<unordered_map> #include<unordered_set> #include<vector> #include<cassert> #include<cs...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> typedef long long LL; const int MN = 41; int N, A[MN][MN]; LL f[MN][MN][MN], g[MN][MN][MN], Ans; int main() { scanf("%d", &N), N <<= 1; for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) scanf("%1d", &A[i][j]); for (int i = 1; i < N; ++i) { f[i][i][i] = 1; for (int j = i + 1; j <...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; #define int long long const int N=45; int f[N][N][N],flag[N][N][N],n,ans; char s[N][N]; int dp(int l,int r,int mid){ if (flag[l][r][mid])return f[l][r][mid]; if (l==r)return 1; if (l==mid||mid==r)return 0; flag[l][r][mid]=1; for (int j=l;j<=mid-1;j++) for (int k=mid+1...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 101; /* math */ ll dp[N][N][N]; int v[N][N][N],n; char E[N][N]; inline ll solve(int a,int b,int c){ if(a==b&&b==c)return 1; if(v[a][b][c])return dp[a][b][c]; v[a][b][c]=1; for(int d=a;d<b;d++){ for(int e=b+1;e<=c;e++){ for(int f=a...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define MN 41 typedef long long ll; int n; ll dp[MN][MN][MN],ans; char mp[MN][MN]; int main() { scanf("%d",&n);n<<=1; for(int i=1;i<=n;i++) scanf("%s",mp[i]+1); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) dp[i][i][j]=(mp[i][j]=='1'); dp[i][i][i]=1; } for(int len=3;len<=n;len+=2) { ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long lol; const int N = 55; int _w; lol f[N][N][N]; int n , G[N][N]; char str[N]; lol dp( int l , int r , int mid ) { if( l == mid || r == mid ) return l == r; if( ~f[l][r][mid] ) return f[l][r][mid]; lol & res = f[l][r][mid]; res = 0; for( int...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i) #define ll long long using namespace std; const int N=50; int n; char a[N][N]; ll f[N][N][N],s[N][N],ss,ans; int main(){ scanf("%d",&n);n*=2; fo(i,1,n)scanf("\n%s",a[i]+1),f[i][i][i]=1; for(int len=2;len<=n-2;len+=2) fo(l,2,n-len){ int r=l+len...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=45,inf=0x3f3f3f3f; int read(){ int f=1,g=0; char ch=getchar(); for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1; for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0'; return f*g; } int n,h[N][N]; ll ans,f[N][N][N]; char ch[N]; int main(){ //...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<cstdio> #include<cstring> using namespace std; #define N 45 long long dp[N][N][N],f[N][N][N][N],n; char s[N][N]; long long calc(int a,int b,int c,int d) { if(f[a][b][c][d]!=-1)return f[a][b][c][d]; long long as=0; for(int i=a;i!=(b==n*2?1:b+1);i=i==n*2?1:i+1) for(int j=c;j!=(d==n*2?1:d+1);j=j==n*2?1:j+1) ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f; for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f; } void print(int x) { if(x<0) putchar('-'),x=-x; if(!x) return ;print(x/10),putchar(x%10+48); } void ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define pb push_back #define mp make_pair #define fi first #define se second #define sz(a) int(a.size()) const int N=50; int gi() { int x=0,o=1;char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define N 55 #define ll long long char s[N][N]; ll dp[N][N][N]; ll getans(int l, int r, int m) { if (dp[l][r][m] != -1) return dp[l][r][m]; if (l == r) return dp[l][r][m] = 1; if (l == m || r == m) return dp[l][r][m] =...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include "bits/stdc++.h" using namespace std; using ll = long long; using vll = std::vector<ll>; using vvll = std::vector<vll>; using vvvll = std::vector<vvll>; using dd = double; using vdd = std::vector<dd>; using vvdd = std::vector<vdd>; using vvvdd = std::vector<vvdd>; constexpr ll INF = 1LL << 60; constexpr dd EPS...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const int maxn=44; #define MP make_pair #define lson o<<1,l,mid #define rson o<<1|1,mid+1,r #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define ROF(i,a,b) for(int i=(a);i>=(b);i--) #define MEM(x,v) memset(x,v,sizeof(x)) inlin...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
JAVA
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define MP make_pair #define PB push_back #define int long long #define st first #define nd second #define rd third #define FOR(i, a, b) for(int i =(a); i <=(b); ++i) #define RE(i, n) FOR(i, 1, n) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define REP(i, n) for(int i = 0;i <(n); ++i)...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; bool chkmax(int &x,int y){return x<y?x=y,true:false;} bool chkmin(int &x,int y){return x...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<cstdio> #include<cstring> using namespace std; #define N 45 long long dp[N][N][N],f[N][N][N][N],n; char s[N][N]; long long calc(int a,int b,int c,int d) { if(f[a][b][c][d]!=-1)return f[a][b][c][d]; long long as=0; for(int i=a;i!=(b==n*2?1:b+1);i=i==n*2?1:i+1) for(int j=c;j!=(d==n*2?1:d+1);j=j==n*2?1:j+1) ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define ll long long #define maxn 45 /*rem*/ #define mod 998244353 #define db double #define vi vector<int> #define pb push_back #define mp make_pair #define pi pair<int, int> #define fi first #define se second using namespace std; ll ksm(ll a, ll b) { if (!b) return 1; ll ns = ksm(a, b >...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<algorithm> #include<cstdio> #define LL long long using namespace std; LL res,ans,f[50][50][50],g[50][50][50]; int n,sl,fh,a[50][50]; int rd() { sl=0;fh=1; char ch=getchar(); while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();} while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar(); return sl*fh; } int m...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cstring> #include <iostream> #define debug(...) fprintf(stderr,__VA_ARGS__) using namespace std; template<class T> void read(T &x) { x=0; int f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();} x*=f; } ty...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <iostream> using namespace std; typedef long long ll; const int MAX_N = 45; ll dp [MAX_N][MAX_N][MAX_N]; ll can [MAX_N][MAX_N]; int main () { int n; cin >> n; n *= 2; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; can[i][j] = c - '0'; } ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cassert> #include <cstring> #include <algorithm> #define meow(args...) fprintf(stderr, args) template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;} template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;} tem...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f[45][45][45], g[45][45][45]; char a[45][45]; int n; int main() { scanf("%d", &n); n <<= 1; for (int i = 1; i <= n; i++) { scanf("%s", a[i] + 1); f[i][i][i] = 1; for (int j = 1; j <= n; j++) { g[i][i][...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; typedef vector<LL> VI; #define MP make_pair #define PB push_back #define X first #define Y second #define FOR(i, a, b) for(LL i = (a); i < (b); ++i) #define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i) #define ITER(it, ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, a[45][45]; ll dp[45][45][45]; ll F(int l, int i, int r) { if (l == r) return 1; ll &ans = dp[l][i][r]; if (~ans) return ans; ans = 0; for (int j = l; j < i; ++j) for (int k = i + 1; k <= r; ++k) if (a[j][k]) for (int p = j; p < i; +...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
/**************************************************************** * Author: huhao * Email: 826538400@qq.com * Create time: 2020-02-15 16:50:22 ****************************************************************/ #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define fr(i,a,b) for(int i=(a),end_#...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define ll long long #define ld long double #define db double #define pint pair<int,int> #define mk(x,y) make_pair(x,y) #define fir first #define sec second #define Rep(x,y,z) for(int x=y;x<=z;x++) #define Red(x,y,z) for(int x=y;x>=z;x--) using namespace std; const int MAXN=45; char buf[1<<12],*...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
JAVA
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define pb push_back #define mp make_pair #define fi first #define se second #define sz(a) int(a.size()) const int N=50; int gi() { int x=0,o=1;char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; const int maxn=85; int n; char s[maxn][maxn]; long long F[maxn][maxn][maxn][maxn],G[maxn][maxn][maxn]; bool visF[maxn][maxn][maxn][maxn],visG[maxn][maxn][maxn]; long long solveF(int l,int r,int ll,int rr); long long solveG(int l,int r,int m); long long solveG(int l,int r,i...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; #define N 42 char s[N][N]; long long dp[N][N][N][N], ep[N][N][N][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; n *= 2; for (int i = 0; i < n; i ++) { cin>>s[i]; for (int j = 0; j < n; j ++) s[i][j] -= '0'; } for (int i = 1;...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <iostream> #include <cstdio> #define MN 42 typedef long long ll; ll s[MN][MN][MN], f[MN][MN][MN], g[MN][MN][MN][MN]; int a[MN][MN]; int main() { int n; scanf("%d", &n); n *= 2; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) scanf("%1d", &a[i][j]); for(int len = 1; len <= n; len++) for(int l ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int) ((x).size())) typedef long long ll; typedef long double ld; int n, a[50][50]; ll dp[50][50][50], cnt[50][50], ddp[50][50][50][50]; ll getNumWays(int al, int ar, int bl, int br) { if (ar < al && br < bl) return 1; if (ar < al || br < bl) ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<iostream> #include<cstdio> #define FOR(i,a,b) for(int i=a;i<=b;i++) using namespace std; typedef long long ll; const int N=44; int n,a[N][N],b[N][N][N]; ll f[N][N][N],ans; char s[N]; ll dfs(int l,int m,int r){ if(l==m && m==r) return 1; if(b[l][m][r]) return f[l][m][r]; b[l][m][r]=1; FOR(i,l,m-1)FOR(j,m+1,...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; #define ll long long ll f[50][50][50]; int d[50][50],n; char s[50]; inline int rd() { int x=0;char ch=getchar(); for (;ch<'0'||ch>'9';ch=getchar()); for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; return x; } int main() { n=rd()*2; for (int i=1;i<=n;i++) { sc...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define Tp template<typename Ty> #define Ts template<typename Ty,typename... Ar> #define Reg register #define RI Reg int #define Con const #define CI Con int& #define I inline #define W while #define N 20 #define LL long long using namespace std; int n,a[2*N+5][2*N+5];LL f[2*N+5][2*N+5][2*N+5]; ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
//#define USEPB_DS #define USETR1 #define CPPELEVEN #define GPP /* * temp.cpp * * Created on: 2012-7-18 * Author: BSBandme */ //#pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream> #include <fstream> #include <string.h> #include <cstdio> #include <algorithm> #include <string> #incl...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define itn int #define all(x) (x).begin(), (x).end() #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) using namespace std; inline int nxt() { int x; scanf("%d", &x); return x; } const int mod = 998244353; const int N = 41; long long dp[N][N][N][N]; long...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 44; int N; ll _F[MAX_N][MAX_N][MAX_N]; char A[MAX_N][MAX_N]; ll F(int l, int i, int r) { ll &res = _F[l][i][r]; if (res != -1) return res; if (l == r) return res = 1; if (r - l & 1) return res = 0; res = 0; ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=45,inf=0x3f3f3f3f; int read(){ int f=1,g=0; char ch=getchar(); for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1; for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0'; return f*g; } int n,h[N][N]; ll ans,f[N][N][N],g[N][N][N]; char ch[N]; int...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define ll long long using namespace std; template<typename tn> void read(tn &a){ tn x=0,f=1; char c=' '; for(;!isdigit(c);c=getchar()) if(c=='-') f=-1; for(;isdigit(c);c=getchar()) x=x*10+c-'0'; a=x*f; } int n; char mp[45][45]; ll f[45][45][45],fs[45][45][45]; int main(){ read(n); for(int...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; int n; char can[45][45]; long long memo[45][45][45]; long long dp(int i,int j,int k){ if ((j^i)&1) return 0; if (i==j) return 1; if (i==k || j==k) return 0; else if (memo[i][j][k]!=-1) return memo[i][j][k]; long long ans=0; for (int x=i;x<k;x++){ for (int y=k...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define ll long long using namespace std; template <typename T> void chkmax(T &x, T y) {x = x > y ? x : y;} template <typename T> void chkmin(T &x, T y) {x = x < y ? x : y;} template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); while (!isdigit(c)) {if (c == '-') f = -1...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; #define ll long long #define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++) #define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--) #define EREP(i,u) for(int i=start[u];i;i=e[i].next) #define fi first #define se second #define mkr(a,b) make_pair(a,b) #define SZ(A) ((int)...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define debug(...) fprintf(stderr, __VA_ARGS__) #ifndef AT_HOME #define getchar() IO::myGetchar() #define putchar(x) IO::myPutchar(x) #endif namespace IO { static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23; inline char myGetchar() { static char buf[IN_BUF], *ps = buf, *pt = buf; if...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> // iostream is too mainstream #include <cstdio> // bitch please #include <iostream> #include <algorithm> #include <cstdlib> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <cmath> #include <iomanip> #include <time.h> #define dibs reserv...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; using ll=long long; const int N = 42; bool g[N][N]; ll dp[N][N][N][N][2]; void solve() { int n; cin >> n; n <<= 1; for (int i = 1; i <= n; i++) { string s; cin >> s; for (int j = 1; j <= n; j++) { g[i][j] = s[j-1] == '1'; }...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; const int maxn=45; int n; char s[maxn][maxn]; long long F[maxn][maxn][maxn][maxn],G[maxn][maxn][maxn]; bool visF[maxn][maxn][maxn][maxn],visG[maxn][maxn][maxn]; long long solveF(int l,int r,int ll,int rr); long long solveG(int l,int r,int m); long long solveG(int l,int r,i...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; const int N = 42; int n; string s[N]; typedef long long ll; ll ans, f[N][N][N], g[N][N][N][N]; ll F(int l, int r, int p); ll G(int a, int b, int c, int d) { if (~g[a][b][c][d]) return g[a][b][c][d]; ll ret = 0; for (int i = a; i <= b; i++) { for (int j = c; j <= d...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> typedef long long ll; const int N=45; ll f[N][N][N],ans; int n,i,j,k,l,r,p,q,l2,r2; char c[N][N]; int main(){ scanf("%d",&n);for(i=1;i<=n*2;++i)scanf("%s",c[i]+1),f[i][i][i]=1; for(i=2;i<n*2;i+=2)for(j=1;j+i<=n*2;++j){ l=j;r=j+i; for(l2=l;l2+1<r;++l2)for(r2=l2+2;r2<=r;++r2){ ll s=0; ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; char mp[41][45]; int n; long long dp[42][42][42][42],dp2[42][42][42][42]; long long calc_dp2(int l,int r,int ll,int rr) ; long long calc_dp(int l,int r,int ll,int rr) ; long long calc_dp(int l,int r,int ll,int rr) { if(dp[l][r][ll][rr] != -1) return dp[l][r][ll][rr]; ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> #define mset(a, b) memset(a, b, sizeof(a)) #define mcpy(a, b) memcpy(a, b, sizeof(a)) #define rg register using namespace std; typedef long long LL; const int N = 45; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #endif using ll = long long; using ld = long double; using D = double; using uint = unsigned int; template<typename T> using pair2 = pair<T, T>; using pii = pair<int, int...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author majk */ #ifndef MAJK_LIB #define MAJK_LIB #include <vector> #include <stack> #include <iostream> #include <unordered_map> #include <unordered_set> #include <map> #include <iomanip> #include <set> #include <functional>...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=20; int n; char e[N*2+9][N*2+9]; void into(){ scanf("%d",&n);n<<=1; for (int i=1;i<=n;++i) scanf("%s",e[i]+1); } LL f[N*2+9][N*2+9][N*2+9],g[N*2+9][N*2+9][N*2+9],ans; void Get_fg(){ for (int i=1;i<n;++i){ f[i][i][i]=1; for (in...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; long long ans,dp[41][41][41]; int n; char a[50][50]; long long solve(int l,int r,int i) { if(l==r)return 1; if(l==i||r==i)return 0; if(~dp[l][r][i])return dp[l][r][i]; long long sum=0; for(int j=l;j<i;++j) for(int k=i+1;k<=r;++k) if(a...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; long long dp[MAXN][MAXN][MAXN]; int A[MAXN][MAXN]; char S[MAXN]; int n; long long ans; long long getAns(int l, int r, int c) { if (dp[l][r][c] != -1) return dp[l][r][c]; if (l == r) return dp[l][r][c] = 1; if (l == c || r == c) return dp[l][r...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<iostream> #include<cstdio> #define LL long long using namespace std; int n; LL ans; const int N=45; char s[N][N]; LL f[N][N][N],g[N][N][N]; int main() { cin>>n;n*=2; for(int i=1;i<=n;++i)scanf("%s",s[i]+1); for(int i=1;i<n;++i) { f[i][i][i]=1; for(int j=i+1;j<=n;++j) if(s[i][j]=='1')g[i][i][j]=1; }...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; int n; char s[51][51]; long long f[51][51][51],ans; int main() { scanf("%d",&n),n<<=1; for (int i=1; i<=n; i++) scanf("%s",s[i]+1); if (n==2) return putchar(s[1][2]),0; for (int i=1; i<=n; i++) f[i][i][i]=1; for (int len=3; len<n; len+=2) for (int i=2,j=i+len-1; j<=...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author majk */ #ifndef MAJK_LIB #define MAJK_LIB #include <vector> #include <stack> #include <iostream> #include <unordered_map> #include <unordered_set> #include <map> #include <iomanip> #include <set> #include <functional>...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 40 + 5; int n, g[maxn][maxn]; ll dp[maxn][maxn][maxn]; char s[maxn]; ll dfs(int l, int r, int m) { if(~ dp[l][r][m]) return dp[l][r][m]; if(l == r) return dp[l][r][m] = 1; if(l == m || r == m) return dp[l][r][m] = 0; ll res = 0; ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; 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 << 3) + (x << 1) + (ch ^ 48); ...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#ifndef BZ #pragma GCC optimize "-O3" #endif #include <bits/stdc++.h> #define ALL(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i < (r); ++i) using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; /* ll pw(ll a, ll b) { ll ans = 1; while (b) { while...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define mp make_pair typedef long long LL; typedef unsigned long long uLL; typedef pair<int,int> pii; bool con[42][42]; int n; LL dp[42][42][42]; LL dfs(int l,int r,int mid) { if(dp[l][r][mid]!=-1)return dp[l][r][mid...
CPP
p02895 AtCoder Grand Contest 039 - Pairing Points
There are 2N points generally positioned on the circumference of a circle, numbered 1,\dots,2N in counterclockwise order. Here, a set of points is said to be generally positioned if, for any six distinct points U, V, W, X, Y, and Z among them, the segments UV, WX, and YZ do not intersect at the same point. Additionally...
6
0
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define REP(i,n) for(int i=(0);i<(n);i++) #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; typedef pair<int,int> pii; typedef vector<int> vi; typedef long lo...
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
n = int(input()) SP = [] for i in range(n): s,p = input().split() SP.append((s,-int(p),i+1)) SP.sort() for s,p,i in SP: print(i)
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n = in.nextInt(); long[] r = new long[n]; for (in...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
#include <bits/stdc++.h> using namespace std; int main() { int N; string S; int P; pair<pair<string, int>, int> p[100]; cin >> N; for (int i = 0; i < N; i++) { cin >> S >> P; p[i] = make_pair( make_pair( S, -P ), i ); } sort(p, p + N); for (int i = 0; i < N; i++) { cout << p[i].second+1 << endl; }...
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int main(){ int n; cin>>n; vector<tuple<string,int,int>> v; for(int i=1;i<=n;i++){ string s; int p; cin>>s>>p; v.emplace_back(s,-p,i); } sort(v.begin(),v.end()); for(auto x:v) cout<<get<2>(...
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
#include <iostream> #include <algorithm> using namespace std; pair<pair<string,int>,int> pa[110]; int main(){ int N; cin >> N; string s; int p; for(int i=0;i<N;i++){ cin >> s >> p; pa[i]=make_pair(make_pair(s,-p),i); } sort(pa,pa+N); for(int i=0;i<N;i++) cout << pa[i].second+1 << endl;; }
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<tuple<string,int,int>> p(n); for(int i=0; i<n; i++){ string s; int t; cin>>s>>t; p[i]=make_tuple(s,100-t,i+1); } sort(p.begin(),p.end()); for(int i=0; i<n; i++){ cout<<get<2>(p[i])<<endl; } }
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
n = int(input()) a = [] for i in range(n): n,k = input().split() k = int(k) a.append([n, -k, i+1]) a.sort() for i in a: print(i[2])
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
n = int(input()) S = [] for i in range(n): a, b = input().split() S.append([a, -int(b), i + 1]) S.sort() for i in S: print(i[2])
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.*; import static java.util.Comparator.*; class Restaurant { private String city; private int score; private int index; public Restaurant(String city, int score, int index) { this.city = city; this.score = score; this.index = index; } public String getCity...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import sys from collections import deque import copy import math def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_fun...
PYTHON
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.*; public class Main { static Scanner scanner = new Scanner(System.in); public static void main(String[]$) { int n = scanner.nextInt(); r[] a = new r[n]; for (int i = 0; i < n; i++) { a[i] = new r(); a[i].s = scanner.next(); a[i].p =...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { static class Restaurant{ public Restaurant(int id, String name, int score) { this.id = id; this.name = name; this.score = score; } int id; String name; int score; } publi...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
N = int(input()) l = [] for i in range(N): s,p=input().split() p=100-int(p) l.append((s,p,i+1)) l.sort() for i in range(N): print(l[i][2])
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
print("\n".join([str(y[0]) for y in sorted([[i + 1] + input().split() for i in range(int(input()))], key=lambda x: (x[1], -int(x[2])))]))
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.awt.*; import java.util.*; import java.util.List; import java.util.stream.Collectors; public class Main { public static int aa = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<String, List<Point>> map = new HashMa...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] S = new String[N]; int[] P = new int[N]; int[] num = new int[N]; for (int i = 0; i < N; i++) { S[i] = sc.next(); P[i...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
N = int(input()) SP = [(i, input().split()) for i in range(1, N+1)] SP.sort(key=lambda x: (x[1][0], -int(x[1][1]))) for x in SP: print(x[0])
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
n = int(input()) lst = [list(input().split())+[i+1] for i in range(n)] for i in sorted(lst, key = lambda x: (x[0], -int(x[1]))): print(i[2])
PYTHON3
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
//package atcoder; import java.util.*; import java.lang.String; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String[] arr=new String[n]; int[][] a=new int[n][2]; for(int i=0;i<n;i++) { arr[i]=s...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
#include<bits/stdc++.h> using namespace std; int main(){ int N;cin>>N; vector<pair<pair<string,int>,int>> vec(N); string s;int a; for(int i=0;i<N;i++){ cin>>s>>a; vec[i].first.first=s; vec[i].first.second=-a; vec[i].second=i+1; }sort(vec.begin(),vec.end()); for(int i=0;i<N;i++){ cout<<vec[i].secon...
CPP
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.Scanner; import java.util.Arrays; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String[] ans = new String[a]; for(int i = 0; i < a; i++){ ans[i] = sc.next() + "_" + (1100 - s...
JAVA
p03030 AtCoder Beginner Contest 128 - Guidebook
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score. You want to in...
6
0
import java.util.*; class Main{ public static void main(String argv[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[][] arrays = new String[N][3]; for(int i=0;i<N;i++){ arrays[i][0] = sc.next(); arrays[i][1] = sc.next(); arra...
JAVA