prompt string | response string |
|---|---|
Problem: Consider a tic-tac-toe on a 3x3 board. Tic-tac-toe is a two-player battle game. Decide the first attack and the second attack, one hits Kuroishi and one hits Shiraishi. The winner is the person who puts stones one by one on the board alternately and arranges three of his own stones first in either the vertical... | import java.util.Scanner;
public class Main
{
public static void main(String arg[])
{
Scanner in= new Scanner(System.in);
while(in.hasNext())
{
char[] c1=in.next().toCharArray();
if(c1[0]=='0')
return;
char[] c2=in.next().toCharArray();
char[] c3=in.next().toCharArray();
if(c1[0]=='b'&&c1[1]... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffffffff
typedef long long int LLI;
int N;
int M;
LLI ts[1145];
LLI ss[1145];
LLI vs[3145];
LLI hs[3145];
LLI dp[1145][3145];
int main() {
scanf("%d%d", &N, &M);
for (int i=1; i<=N; i++) {
scanf("%lld%lld", &vs[i], &hs[i]);
}
for (int i=1;... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define Vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace s... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
using namespace std;
inline void chmax(int &a, int b) { a = max(a, b); }
int n, m;
int v[3005], h[3005];
int t[1005], s[1005];
int isok[3005][1005] = {};
int dp[1005][3005][2];
int main()
{
bool ans = false;
cin >> n >> m;
fill_n(**dp, 1005 * 3005 * 2, -1);
v[0] = 0;
for(in... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
int N, M;
cin >> N >> M;
vector<LL> v(N+1), h(N+1);
for(auto i = 1; i <= N; ++i) cin >> v[i] >> h[i];
vector<LL> t(M+1), s(M+1);
for(auto i = 1; i <= M; ++i) cin >> t[i] >> s[i];
for(auto i = 1; i <= N; ++i) v[i] += v[i-1... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<iostream>
#include<algorithm>
#include<complex>
using namespace std;
typedef long long ll;
#define N 3010
#define M 1010
#define chmax(a,b) a=max(a,b);
ll n,m,v[N],h[N],t[M],s[M];
ll f[M][N],g[M][N],l[M];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>v[i]>>h[i];
for(int i=1;i<=m;i++)cin>>t[i]>>s... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define NUM 3000
#define SIZE 1000
enum Type{
pre_no,
pre_yes,
};
int num_item,num_event;
int price[NUM],add[NUM];
int TIME[SIZE],nee... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
using namespace std;
int N,M;
int v[3000],h[3000];
int t[3000],s[3000];
int dp[3001][3001][2];
void maxf(int &a,int b){
a=max(a,b);
}
int main(){
cin>>N>>M;
for(int i=0;i<N;i++){
cin>>v[i]>>h[i];
if(i>0)v[i]+=v[i-1];
}
for(int i=0;i<M;i++){
cin>>t[i]>>s[i];
}
for(i... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | bool debug=false;
#include <stdio.h>
const int N=3e3+10;
const long long int INF=1e16+10;
long long int max(long long int a,long long int b){return a>b?a:b;}
int ABS(int n){return n>=0?n:-n;}
long long int sv[N],s[N],le[N],dp[N][N];
int v[N],h[N],t[N],a[N],can[N];
void pre(int n,int m){
s[0]=le[0]=0;
s[1]=h[1];
for(... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using name... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main() {
long long N,M;
cin >> N >> M;
vector<long long> h(2*N,0),v(N+1,0),t(M),s(M);
long long i,j,k;
for(i=0;i<N;i++) {
cin >> j;
v[i+1] = v[i] + j;
cin >> j;
if(i>0)h[2*i] = h[2*i-1]+abs(j-(h[2*i-1]-h[2*i-... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
using namespace std;
void chmax(int &a, int b)
{
a = max(a, b);
}
int N, M, V[3000], H[3000], T[1000], S[1000];
void solve()
{
cin >> N >> M;
for(int i = 0; i < N; i++) {
cin >> V[i] >> H[i];
if(i) V[i] += V[i - 1];
}
for(int i = 0; i < M; i++) {
cin >> T[i] >> S[i];
... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define fi first
#define se second
template<typename A,typename B>inline vo... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
const int INF=0x3f3f3f3f;
int v[5000],h[5000];
int t[5000],s[5000];
int dp[5000][5000];
int main(){
int n,m;cin>>n>>m;
rep(i,n){
scanf("%d%d",&v[i],&h[i]);
}
rep(i,m){
scanf("%d%d",&t[i],&s[i]);
}
rep(i,m+1)rep(j,n+1)dp[i]... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);
using namespace std;
namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(cons... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
#define N 3010
#define M 1010
#define int long long
using namespace std;
int n,m;
int v[N],h[N];
int t[M],s[M];
int Max(int &a,int b){return a = max(a,b);}
int dp[M][N][2];
int DP(){
memset(dp,-1,sizeof(dp));
dp[0][0][0] = 0;
for(int i=0;i<m;i++){ //monster
int money = t[i];
... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const i64 INF = 1e18 + 7;
const i64 MOD = 1e9 + 7;
signed main(){
i64 n, m;
cin >> m >> n;
vector<i64> cost(m), power(m);
for(i64 i = 0; i < m; ++i)
cin >> cost[i] >> power[i];
vector<i64> time(n), required(n);
for(... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define MP make_pair
#define INF 1e9
#define F first
#define S second
using namespace std;
typedef long long LL;
#define int LL
typedef pair<int, int> P;
int N, M, n, ans = -1;
vector<int> v, h, t, s, vrsk;
int ... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include "bits/stdc++.h"
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);
using namespace std;
namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(cons... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (l... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define MP make_pair
#define INF 1e9
#define F first
#define S second
using namespace std;
typedef long long LL;
#define int LL
typedef pair<int, int> P;
int N, M, ans = -1;
int dp[1010][3010][2], v[3010], h[301... |
Problem: You found an old board game in your programming department's room. It looks interesting so I decided to play with it.
This game consists of M events and you must capture event i at time ti. However, at that time your strength must be si or better, and if you can't be si or better, the game is over. Your stren... | #include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define INF 2e+9
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int siz,segMax[300000],segAdd[300000],bit[300010];
void b_add(int i,int x){
while(i <= siz){
bit[i] += x;
i += i & -i;
}
}
int sum(int i){
int s = 0;
whi... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x)... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | //omaerapakurunakasuwwwwwwww(^o^)9m
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int B = 1<<17;
struct SegmentTree{
struct vd{
int v;
int delay;
vd():v(0),delay(0){}
} data[B*2];
int s;
void Initialize(int size){
s=1... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 100005
struct Info{
Info(){
mid_index = 0;
value = 0;
}
Info(int arg_mid_index,... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define MAX_N (100000)
using namespace std;
typedef long long lint;
lint bit[MAX_N + 1];
void add(int pos)
{
for (; pos <= MAX_N; pos += pos & -pos)
bit[pos] += 1;
}
lint sum(int pos)
{
lint ret = 0;
for (; pos; pos &= (pos - 1... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int B = 1<<17;
struct SegmentTree{
struct vd{
int v;
int delay;
vd():v(0),delay(0){}
} data[B*2];
int s;
void Initialize(int size){
s=1;
while(s<size) s<<=1;
}
inline void PassDelay(int idx){
data[idx*2].d... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <bits/stdc++.h>
using namespace std;
const int64_t inf = 1001001001001001001ll;
template <typename T> class Compress {
private:
size_t sz;
std::vector<T> zip;
std::vector<int> formatted;
public:
Compress(std::vector<T> &v) : formatted(v.size(), -1), sz(v.size()) {
zip = v;
std::sort(zip.begi... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
const int N = 100005;
int n, m;
int a[N];
int bit[N];
int it[4 * N];
int lz[4 * N];
vector<int> val;
vector<int> v[N];
vector<int> start;
vector<int> finish;
void upd(int x) {
for (int i = x; i > 0; i -= i & -i) bit[i]++;
}
int get(int x) ... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <tuple>
using namespace std;
template<typename Type> class StarrySkyTree {
public:
unsigned size_; std::vector<Type> dat1, dat2, dat;
inline void update_(unsigned a, unsigned b, Type x, unsigned k, unsigned l, unsigned r) {
if (r... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include <bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef long long ll;
typedef pair <int, int> ii;
#define X first
#define Y second
#define mk make_pair
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
const int MOD = (int) 1e9 + 7;
void MAIN();
int main(){
//freopen("input.txt", "r", stdin)... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<stdio.h>
#include<algorithm>
using namespace std;
int b[110000];
int z[110000];
long long bit[110000];
long long sum(int a,int b){
if(a)return sum(0,b)-sum(0,a-1);
long long ret=0;
for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
return ret;
}
void add(int a,int b){
for(;a<110000;a|=a+1)bit[a]+=b;
}
int segtree[26214... |
Problem: Bubble Sort
Bubble sort is one of the algorithms for sorting columns. Suppose you want to sort the sequence A of length N in ascending order. Bubble sort exchanges the positions of two adjacent numbers if the magnitude relationship is broken. This is done while scanning the sequence from the front. That is, i... | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
using namespace std;
typedef long long ll;
#define N (1<<17)
int n,m[N];
void Zaats(){
vector<int> v;
lol(i,n)v.push_back(m[i]);
sort(v.begin(),v.end());
lol(i,n){
m[i]=l... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<bitset>
#include<cmath>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
using namespace std;
struct Puzzle
{
char t,r,b,l;
Puzzle(char t='$',char r='$',char b='$',char l='$'):... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <bits/stdc++.h>
using namespace std;
char p[3][3][4];
char pz[9][5];
bool check(char a,char b){
return (a-32 == b || b-32 == a);
}
int rec(int now,int S){
if(now == 9) return 1;
int res = 0;
int X = now%3, Y = now/3;
for(int s = 0 ; s < 9 ; s++){
if(S >> s & 1) continue;
... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
using namespace std;
char pie[9][4], dat[3][3][4];
bool used[9];
int ans, T;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
void rec(int y, int x){
//cout << y << ' ' << x << endl;
if(y == 3){ ans++; return; }
for(int i=0;i<9;i++){
if(used[i]) continue;
u... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#in... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#def... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
// Peace::elem->[0]:up,[1]:right,[2]:buttom,[3]:left
struct Peace{
char elem[4];
void rotate(){
char tmp=elem[3];
elem[3]=elem[2];
elem[2]=elem[1];
elem[1]=elem[0];
elem[0]=tmp;
}
... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
const int MAX = 9;
const int TOP = 0;
const int RIGHT = 1;
const int BOTTOM = 2;
const int LEFT = 3;
bool used[MAX];
string puz[MAX];
string tmp[MAX];
int ans;
void rotate(int n){
string s = "";
s = puz[n].substr(1);
... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<stdio.h>
#include<algorithm>
using namespace std;
char str[10][10];
int v[10];
char p[10][5];
int solve(int a){
if(a==9)return 1;
int ret=0;
for(int i=0;i<9;i++){
if(!v[i]){
v[i]=1;
for(int j=0;j<4;j++){
if(a%3){
if((str[i][(j+3)%4]^32)!=p[a-1][1])continue;
}
if(a/3){
if((str[i... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int n;
char str[9][5];
char fie[3][3][5];
int cnt;
bool used[9];
char data[8]={'g','w','r','b','G','W','R','B'};
void swap(int x,int y){
char d=fie[x][y][0];
for(int i=0;i<3;i++){
fie[x][y][i]=fie[x][y][i+1];
}
fie[x][y][3]=d;
}
void ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class Main{
Scanner sc=new Scanner(System.in);
int T;
final int m=3, n=9;
String[] ss;
void run(){
T=sc.nextInt();
fo... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
public static final int MAX = 3;
public static final int SIZE = MAX * MAX;
public static int[][] move_dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
public static int[] use... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
int cnt;
//vector<string> memo;
char tonum(char word) {
if(word == 'R') return '1';
if(word == 'G') return '2';
if(word == 'B') return '3';
if(word ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <string>
#include <cmath>
using namespace std;
char mp[3][3][4];
string str[10];
bool used[9];long long cnt,ans;
void saiki2(int num){
int ex[] ={0,0,2,2};
int ey[] ={2,0,0,2};
int tx[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int ty[4][2] = {{0,-1},{1,0},{0,1},{-1,0}};
if(num == 4) ans... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
const int correct = abs('a' - 'A');
int ans = 0;
vector<string> vec(9);
vector<vector<string> > piece(3,vector<string>(3));
vector<vector<int> > offset(3,vector<int>(3,0));
vector<int> used(9,0);
bool valid(... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
using namespace std;
string s[9];
int indeces[9];
int ans;
void rec(int n){ // n テ」ツつ津ァツスツョテ」ツ??
int nn = n-1; // nn テ」ツ?セテ」ツ?ァテァツスツョテ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツつ?
if( n>0 && nn%3!=0 ){ // check left
char a = s[indeces[nn-1]][1];
char b = s[indeces[nn]][3];
if(b<a) swap(a,b );
switch(... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;
string puzzle[9];
int pl2id[9], pl2rot[9];
bool check(char a, char b) {
return toupper(a) == toupper(b) && a != b;
}
int dfs(int k, bool *used) {
if(k == 9) return 1;
int ret = 0;
for(int id=0; id<9; id++) {
if(used[id]) ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;
#define H 3
#define W 3
#define N 9
class Piece {
public:
char top, right, bottom, left;
Piece(string s=" ") :top(s[0]), right(s[1]), bottom(s[2]), left(s[3]) {}
void rotate() {
swap(top, right);
... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | //15
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
string b[9];
string p[9];
bool cn(char a,char b){
return a!=b&&tolower(a)==tolower(b);
}
int dfs(int x,int u){
if(x==9){
return 1;
}else{
int r=0;
for(int i=0;i<9;i++){
if(!(u>>i&1)){
for(int ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <bits/stdc++.h>
using namespace std;
char arr[5][5][4];
char puzzle[36][4];
bool used[36];
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
bool check(char a, char b){
int d = -32;
return (a + d == b || b + d == a || a == '0' || b == '0');
}
int rec(int y, int x){
if(y == 4 && x == 1){
r... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
enum Loc{
Top,
Right,
Under,
Le... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
vector<strin... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#in... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.*;
class Main{
String[][] puzzle;
String[][] field;
boolean[] used;
void run(){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int attend=0;attend<n;attend++){
field =new String[3][3];
puzzle=new String[9][4];
used=new boolean[9];
for(int i=0;i<9;i++)... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <cmath>
using namespace std;
void func(int);
bool Check(char,char);
char board[4][4][4];
char data[9][4];
bool used[9];
int cnt;
int main(){
int n;
string str;
cin >> n;
while(n){
n--;
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
for(int k=0;k<4;k++)
board[i][... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#in... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class P{
public:
int d,r;
};
int data,res;
vector<string>sv;
int dy[] = {-1,0,1,0};
int dx[] = {0,1,0,-1};
void input(){
string tmp;
sv.clear();
for(int i = 0 ; i < 9 ; i++)cin >> tmp,sv.push_back(tmp);
}
bool ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;
string puzzle[9];
int pl2id[9], pl2rot[9];
bool check(char a, char b) {
return toupper(a) == toupper(b) && a != b;
}
int dfs(int k, bool *used) {
if(k == 9) return 1;
int ret = 0;
for(int id=0; id<9; id++) {
if(used[id]) ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.*;
public class Main {
final int INF = 1 << 24;
HashMap<C,C> pass;
int ans;
String [][] data;
char [][] map;
String [] store;
boolean [] used;
HashMap<Character, Character> change;
class C{
int pos ,ind;
public C(int pos, int ind) {
this.pos = pos; this.ind = ind;
}
}
private v... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <array>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <stack>
#include <vector>
using namespace std;
int result = 0;
char Map[9][4];
bool check[9];
int t_map[3][3];
int... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;
string puzzle[9];
int pl2id[9], pl2rot[9];
bool check(char a, char b) {
return toupper(a) == toupper(b) && a != b;
}
int dfs(int k, bool *used) {
if(k == 9) return 1;
int ret = 0;
for(int id=0; id<9; id++) {
if(used[id]) ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <cmath>
using namespace std;
string ps[10];
char mp[4][4][4];
int ans,used[10];
int dx[] = {1,2,3,1,2,3,1,2,3};
int dy[] = {1,1,1,2,2,2,3,3,3};
void saiki(int kai){
if(kai == 9)ans++;
else
for(int i=0;i<9;i++) {
if(used[i] == 1) continue;
for(int j=0;j<4;j++){
int flg... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | p_ch = [True] * 9
rot = ((0, 1, 2, 3), (1, 2, 3, 0), (2, 3, 0, 1), (3, 0, 1, 2))
adj = ['c'] * 13
# record indices of right and botoom adjacent edge label. 12 is invalid.
rec_adj = [[0, 2], [1, 3], [12, 4], [5, 7], [6, 8], [12, 9], [10, 12],
[11, 12], [12, 12]]
# refernce indices to top and left adjacent e... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class Piece {
public:
string s;
string getTurnR(int n) {
string tmp = s;
for(int i = 0; i < n; i++) {
for(int j = 0; j < 4; j++) {
tmp[j] = s[(j+3)%4];
}
}
return tmp;
}
//n=0123:trdl
char get... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<bitset>
#include<cmath>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
using namespace std;
struct Puzzle
{
char t,r,b,l;
Puzzle(char t='$',char r='$',char b='$',char l='$'):t(... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <cstdlib>
#include <iostream>
using namespace std;
constexpr int SIZE = 3;
constexpr int N = SIZE * SIZE;
constexpr int correct = 'a' - 'A';
string pieces[N];
int ans;
int turn[SIZE][SIZE];
int put[SIZE][SIZE];
bool used[N];
inline bool match(char a, char b) {
return abs(a - b) == correct;
}
void dfs(int... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstr... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int R = 3;
const int L = R*R;
string P[L];
pair<int,int> G[R][R];
bool used[L];
char getC(const string &s, int diff, int dir) {
return s[(dir-diff+4)%4];
}
int rec(int x, int y, int k) {
if(x == 3) {
x = y+2;
y = 2;
}... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
char s[9][5], t[3][3][5];
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 };
int dfs(int p) {
int res = 0;
rep(i, 3)rep(j, 3) {
if (t[i][j][0])continue;
rep(k, 4) {
rep(l, 4) {
int nx = i + dx[l], ny = j + dy[l];
if (nx < 0 || 3 ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif
using na... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.Scanner;
public class Main {
/**
* @param args
*/
static Puzzle[][] p = new Puzzle[5][5];
static Puzzle[] tmp;
static int ans;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int N = cin.nextInt();
while(N--!=0){
p = new Puzzle[5][5];
tmp = new Puzz... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.Scanner;
public class Main{
static char[][] input = new char[9][4];
static char[][] puzzles = new char[9][4];
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int cnt = Integer.parseInt(s.nextLine());
for(int i=0 ; i<cnt ; i++) {
String[] tmp = s.nextLine().sp... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cstring>
using namespace std;
#define TOP 0
#define RIGHT 1
#define BOTTOM 2
#define LEFT 3
const char aToA = 'A' - 'a';
inline bool check( char a, char b )
{
return a == b + aToA || a +... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
string s[9], t[3][3];
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 };
int dfs(int p) {
int res = 0;
rep(i, 3)rep(j, 3) {
if (!t[i][j].empty())continue;
rep(k, 4) {
rep(l, 4) {
int nx = i + dx[l], ny = j + dy[l];
if (nx < 0 || ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<bitset>
#include<cmath>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
using namespace std;
struct Puzzle
{
char t,r,b,l;
Puzzle(char t='$',char r='$',char b='$',char l='$'):t(... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdli... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <cstdlib>
#include <iostream>
using namespace std;
constexpr int SIZE = 3;
constexpr int N = SIZE * SIZE;
constexpr int correct = 'a' - 'A';
string pieces[N];
int ans;
int turn[SIZE][SIZE];
int put[SIZE][SIZE];
bool used[N];
inline bool match(char a, char b) {
return abs(a - b) == correct;
}
void dfs(int... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <algorithm>
using namespace std;
char pie[9][4], dat[3][3][4];
bool used[9];
int ans, T;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
void rec(int y, int x){
if(y == 3){ ans++; return; }
for(int i=0;i<9;i++){
if(used[i]) continue;
used[i] = true;
for(int j=0;j<4;... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | import java.util.Scanner;
//Jigsaw Puzzles for Computers
public class Main{
int trans(char ch){
return ch=='R'?1:
ch=='r'?-1:
ch=='G'?2:
ch=='g'?-2:
ch=='B'?3:
ch=='b'?-3:
ch=='W'?4:-4;
}
class R{
int a[], top;
public R(int[] a, int top) {
this.a = a;
this.top = top;
}
}
R[][... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
char s[9][5], t[3][3][5];
int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 };
int dfs(int p) {
int res = 0;
rep(i, 3)rep(j, 3) {
if (t[i][j][0])continue;
rep(k, 4) {
rep(l, 4) {
int nx = i + dx[l], ny = j + dy[l];
if (nx < 0 || 3 ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
char piece[9][4];
void rot(int i) {
rep (j, 3) swap(piece[i][j], piece[i][j + 1]);
}
bool ok(char a, char b) {return (a ^ b) == 32;}
int solve(int i, int j) {
int res = 0;
rep (k, ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <bits/stdc++.h>
using namespace std;
char p[3][3][4];
char pz[9][5];
bool check(char a,char b){
return (a-32 == b || b-32 == a);
}
int rec(int now,int S){
if(now == 9) return 1;
int res = 0;
int X = now%3, Y = now/3;
for(int s = 0 ; s < 9 ; s++){
if(S >> s & 1) continue;
... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <cstdio>
#include <algorithm>
using namespace std;
char grid[5][5][4];
char puzzles[9][7];
bool mask[5][5]={
{1,1,1,1,1},
{1,0,0,0,1},
{1,0,0,0,1},
{1,0,0,0,1},
{1,1,1,1,1}
};
const int diff=abs('A'-'a');
int solve(int pos,int comb){
// printf("pos=%d\n",pos);
if (pos>=9) return... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define TOP 0
#define BOTTOM 2
#define RIGHT 1
#define LEFT 3
int dx[] = {3,-1,-3,1};
int pt[] = {TOP,RIGHT,BOTTOM,LEFT};
int my[] = {BOTTOM,LEFT,TOP,... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<string>
#define INF 9999999
using namespace std;
int ans,n,used[36],t[5][5][4];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
char pz[36][4];
string str;
void init();
int judge(char,char);
void dfs(int,int);
int main(){
cin>>n;
for(int I=0;... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <cctype>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).beg... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include ... |
Problem: Ordinary Jigsaw puzzles are solved with visual hints; players solve a puzzle with the picture which the puzzle shows on finish, and the diverse patterns of pieces. Such Jigsaw puzzles may be suitable for human players, because they require abilities of pattern recognition and imagination.
On the other hand, "... | #include<iostream>
#include<cmath>
using namespace std;
int n;
string p[9];
bool use[9];
int dir[9],id[9];
int rec(int d){
if(d==9)return 1;
int res = 0;
for(int i=0;i<9;i++){
if(use[i])continue;
use[i] = true;
for(int j=0;j<4;j++){
if(d>2){
if(abs( p[id[d-3]][(2+dir[d-3])%4] - p[i][j] ) !=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.