Source stringclasses 1
value | Date int64 2.01k 2.02k | Text stringlengths 22 783k | Token_count int64 20 394k |
|---|---|---|---|
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
// type {{{
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
// }}}
// macro {{{
#define REP(i,n) for (... | 990 |
Project_CodeNet | 2,014 | #include <iostream>
#include <cstring>
using namespace std;
const int MAX_N = 8;
int h, w, c;
int field[6][MAX_N][MAX_N];
int old;
/*
int field1[MAX_N][MAX_N];
int field2[MAX_N][MAX_N];
int field3[MAX_N][MAX_N];
int field4[MAX_N][MAX_N];
int field5[MAX_N][MAX_N];
*/
void debug(int m) {
for (int i = 0; i < MAX_N; i... | 842 |
Project_CodeNet | 2,014 | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int h,w,c,ans;
int dw[4]={1,0,-1,0},dh[4]={0,1,0,-1};
void dfs(int cell[8][8],int rank){
rank++;
if(rank==5){
if(cell[0][0]!=c){
int tmp=cell[0][0];
queue<P> que;
que.push(P(0,0));
cell[0][0]=c... | 722 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
void dfs(int c, vector<int> v, vector<vector<int>> &vv)
{
v.push_back(c);
if (v.size() == 6)
{
vv.push_back(v);
return;
}
for (int i = 1; i <= 6; i++)
{
auto x = v;
if (i == c)
continue;
dfs(i, x, ... | 687 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
void cdfs(int y,int x,int fromcolor,int tocolor,int &count,vector<vector<int> >&p){
//printf(" y: %d, x: %d, %d -> %d\n", y, x, fromcolor, tocolor);
p[y][x]=tocolor;
count++;
for(int i = ... | 734 |
Project_CodeNet | 2,015 | #include <iostream>
#include <vector>
#include <numeric>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define re... | 812 |
Project_CodeNet | 2,017 | #include <iostream>
#include <vector>
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int h;
int w;
int c;
int count(vector< vector<int> > &p, int b, int i, int j){
int cnt = 1;
for(int k = 0; k < 4; ++k){
if(i+dx[k] >= 0 && i+dx[k] < h &&
j+dy[k] >= 0 && j+dy[k] < w &&
p[i+dx... | 587 |
Project_CodeNet | 2,013 | #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#def... | 744 |
Project_CodeNet | 2,014 | #include <iostream>
#include <vector>
//#include <queue>
using namespace std;
#define MAX 10
typedef vector<int> vec;
int w, h, c;
//int model[MAX][MAX];
int cnt;
//queue<pair<int, int> > que;
int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
int change( int cp[MAX][MAX], int x, int y, int prev, int color ){
cp[y... | 547 |
Project_CodeNet | 2,018 | #include <iostream>
#include <vector>
using namespace std;
int h,w,c;
int data[8][8];
int done[8][8];
int change(int x,int y,int color,int to){
if(y >= h || x < 0 || y < 0 || x >= w) return 0;
if(data[y][x] != color) return 0;
else data[y][x] = to;
if(done[y][x] == true) return 0;
else done[y][... | 638 |
Project_CodeNet | 2,011 | #include <iostream>
#include <cstring>
using namespace std;
int h, w, c;
int panel[2][8][8];
int visit[8][8];
int sq, ans;
void bfs(int x, int y, int cl, int pg)
{
if( x < 0 || x >= w || y < 0 || y >= h || panel[pg][y][x] != cl || visit[y][x] == 1 )
return;
else
{
visit[y][x] = 1;
sq++;
bfs(x+1, y, cl, pg... | 883 |
Project_CodeNet | 2,011 | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int search(const vector< vector<int> > cur, int target, int depth){
int res = 0;
int h = cur.size(), w = cur[0].size();
for(int i=1;i<=6;i++){
if(depth==5&&i!=target) continue;
if(cu... | 401 |
Project_CodeNet | 2,014 | #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair
const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1,... | 884 |
Project_CodeNet | 2,012 | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include... | 899 |
Project_CodeNet | 2,019 | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=... | 679 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;
template <typename T = i64>
struct Range{
struct iterator{
T value;
const T step, last;
const T& operator*(){return value;}
iterator(T value, T step, T last) :
... | 1,620 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int ans,h,w,c;
int tmp;
int flag[8][8];
void print(int panel[8][8]){
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(j) cout<<" ";
cout<<panel[i][j];
}
cout<<endl;
}
}
void dfs2(int y,int x,int ... | 590 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int dfs(vector<vector<int>> p, int s, int c){
int ans = 0;
int H = p.size();
int W = p[0].size();
for (int i = 1; i <= 6; i++){
if (s == 4 && c != i){
continue;
}
vector<vector<int>> q... | 525 |
Project_CodeNet | 2,011 | #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin... | 739 |
Project_CodeNet | 2,017 | #include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(int argc, char *argv[])
{
for(;;) {
int h, w, c;
cin >> h >> w >> c;
if(h == 0) break;
int fld[64];
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {
... | 777 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > mat;
int h,w,c;
int dx[]={0,1,-1,0};
int dy[]={1,0,0,-1};
int change(mat& panel,int color) {
int cnt=1;
queue<pair<int,int> > q;
vector<vector<bool> > used(h,vector<bool>(w));
used[0][0]=true;
q.push({0,0});
while(!q.empty()) {
pair... | 384 |
Project_CodeNet | 2,011 | #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
using name... | 1,050 |
Project_CodeNet | 2,012 | #include <iostream>
using namespace std;
int p[10][10]={0};
int h,w,c;
int count_max=0;
int maxx;
void count_panel(int x, int y, int p[10][10]){
int prev=p[x][y];
p[x][y] = 0;
maxx++;
if(p[x-1][y]==prev) count_panel(x-1,y,p);
if(p[x][y-1]==prev) count_panel(x,y-1,p);
if(p[x+1][y]==prev) count_panel(x+1,y,p);
i... | 523 |
Project_CodeNet | 2,014 | #include <bits/stdc++.h>
using namespace std;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
typedef struct{
char mp[10][10];
}M;
M zero,flg,ch;
vector<string>V;
void init(string s){
if(s.size()==5){
V.push_back(s);
return;
}
for(char c='1';c<='6';c++){
init(s+c);
}
}
void saiki(int x,int y){
if(flg.mp[x][y... | 521 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":... | 836 |
Project_CodeNet | 2,015 | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,c,ans,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
bool check(int x,int y) {
return x>=0 && x<n && y>=0 && y<m;
}
void solve(vector<int> a[], int t) {
int e=a[0][0];
for(int k=1; k<=6; k++) {
if(t<5 && k==e) continue;
if(t==5 && k!=e) c... | 447 |
Project_CodeNet | 2,017 | #include <cstdio>
#include <vector>
#include <algorithm>
static const int di[]={-1, 0, 1, 0};
static const int dj[]={0, -1, 0, 1};
int count(std::vector<std::vector<int> > &p, int i=0, int j=0) {
int res=1;
const int H=p.size(), W=p[0].size();
int orig=p[i][j];
p[i][j] = 0;
for (int k=0; k<4; ++k) {
int... | 608 |
Project_CodeNet | 2,012 | #define _USE_MATH_DEFINES
#define INF 100000000
#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>
#include <list>
#incl... | 896 |
Project_CodeNet | 2,019 | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#define int long long
using namespace std;
class Solver {
};
signed main() {
while (true) {
int h, w, c;
cin >> h >> w >> c;
if (h == 0)break;
int all = pow(5, 5);
vector<vector<int>> grid(h, ve... | 873 |
Project_CodeNet | 2,013 | #include <iostream>
#include <algorithm>
#include <queue>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> PII;
const int MAX_HW = 8 + 2;
const int MAX_C = 6;
int dy[] = { -1, 0, 1, 0 };
int dx[] = { 0, -1, 0, 1 };
int H, W, C;
int fd[MAX_HW][MAX_HW];
int tp[MAX_HW][MAX_HW];
bool used[... | 870 |
Project_CodeNet | 2,011 | #include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ISIN(x, y, w, h) (x >= 0 && x < w && y >= 0 && y < h)
#define f first
#define s second
using namespace std;
pair<int, int> joint[70];
int h, w, c;
int p[8][8];
bool f[8][8];
const int dx[4... | 569 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
struct P {
int p[8][8];
};
const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};
int h, w, c;
bool contain(int y, int x) {
return y >= 0 && y < h && x >= 0 && x < w;
}
P change(int col, P curr) {
queue<pii> que;
qu... | 771 |
Project_CodeNet | 2,014 | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#de... | 777 |
Project_CodeNet | 2,012 | #include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int w,h,c;
int ans;
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int dfs(vector<vector<int> > f){
queue<P> que;
int fc=f[0][0];
que.push(P(0,0));
int a=0;
vector<vector<bool> > used(h,vector<bool>(w,false));
wh... | 582 |
Project_CodeNet | 2,019 | #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<int,P>Q;
#define fi first
typedef long long ll;
#define sc second
int x[10][10],f[10][... | 488 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef uns... | 987 |
Project_CodeNet | 2,013 | #include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void printMap(int** map){
for(int y=0;y<8;y++){
for(int x=0;x<8;x++) printf("%4d",map[y][x]);
cout << endl;
}
getchar();
}
int countUpPanel(int** map,int x,int y,int color,int w, int h){
int sum=0;
if(!(x>=0 && y... | 1,046 |
Project_CodeNet | 2,017 | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define s second
#define f first
#define mk make_pair
using namespace std;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int h,w,c,a[9][9];
int check(int a[9][9]){
queue<pair<int,int> >q;
int used[9][9]={},res=0;
used[0][0]=1;
q.push(mk(0,0));
while(!q.empty()){
... | 509 |
Project_CodeNet | 2,015 | #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int MAX_W=8;
struct panel{
panel(){}
panel(const panel& pnl){
REP(i,MAX_W)REP(j,MAX_W)p[j][i]=pnl.p[j][i];
}
int p[MAX_W][MAX_W];
};
int w,h,c;
void draw(pane... | 615 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cer... | 1,206 |
Project_CodeNet | 2,012 | //8:45
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
void ff(int (*p)[8],int c,int y,int x){
if(c==p[y][x])return;
int b=p[y][x];
p[y][x]=c;
for(int i=0;i<4;i++){
if(0<=y+dy[i]&&y+dy[i]<8&&0<=x+dx[i]&&x+dx[i]<8&&b==p[y+dy[i]][x+dx[... | 473 |
Project_CodeNet | 2,013 | #include <iostream>
#include <vector>
using namespace std;
int h,w,c;
int p[10][10];
int ans;
struct data{
int i,j;
data(int a,int b){i=a;j=b;}
};
bool isVisit[10][10];
int di[]={0,0,1,-1}, dj[]={1,-1,0,0};
int count(int i, int j){
if( i<0||j<0 ) return 0;
if( i>=h||j>=w ) return 0;
if( isVisit[i][j] ) retu... | 690 |
Project_CodeNet | 2,016 | #include <iostream>
#include <algorithm>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
const int H = 8, W = 8, C = 6;
struct State{
int board[H + 2][W + 2];
};
typedef pair<int, int> P;
State duplicate(State& s){
State d;
for(int i = 0;i <= H + 1;++i){
for(int j = 0;j <= W + 1;++j){... | 806 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
for (size_t i = 0; i < v.size(); ... | 864 |
Project_CodeNet | 2,020 | #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
int H,W,C,diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
struct Info{
int table[8][8],count;
};
struct Data{
Data(int arg_row,int arg_col){
row = arg_row;
col... | 1,392 |
Project_CodeNet | 2,012 | #include <iostream>
#include <cstring>
using namespace std;
#define REP(i,a,n) for(i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
bool used[10][10];
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
int ope[5],field[10][10],w,h,c;
int marking(int x, int y, int color){
if( x < 0 || y < 0 || x >= w || y... | 645 |
Project_CodeNet | 2,015 | function bomb(y,x,first,color){
var dy=[-1,0,0,1];
var dx=[0,-1,1,0];
for(var i=0;i<4;i++){
var X=x+dx[i];
var Y=y+dy[i];
if(X<0 || Y<0 || X>=w || Y>=h)continue;
if(yx[Y][X]==first){
yx[Y][X]=color;
cnt++;
bomb(Y,X,first,color);
}
}
}
var input = requ... | 408 |
Project_CodeNet | 2,014 | <?php
/*
AOJ 1174
title:Identically Colored Panels Connection
@kankichi573
*/
function paint($h,$w,$y,$x,&$p,$org,$c)
{
if($org==$c)
return;
if($p[$y][$x]!=$org)
return;
$p[$y][$x]=$c;
if($x>0)
paint($h,$w,$y,$x-1,$p,$org,$c);
if($x<$w-1)
paint($h,$w,$y,$x+1,$p,$org,$c);
i... | 689 |
Project_CodeNet | 2,017 | // Aizu 1174: Identically Colored Panels Connection
// 2017.9.17 bal4u@uu
#include <stdio.h>
#include <string.h>
typedef struct { int r, c; } Q;
Q q[70]; int top, end;
char mk[8][8];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char map[8][8]; int h, w, color;
int ans;
int count(char p[8][8])
{
int i, r, c, r2, c2, ... | 787 |
Project_CodeNet | 2,016 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define repl(i,a,b) for(i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define max(x,y) x>y?x:y
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
typedef int bool;
#define true 1
#define false 0
int dd[]={-1,0,1,0,-1};
int h,w,c;
int p[1... | 569 |
Project_CodeNet | 2,015 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int max(int a,int b){
if(b>a)return b;
return a;
}
int p[10][10];
int cp[10][10];
int flag[10][10];
int h,w,c;
struct data{
int x,y;
};
struct data que[5000000];
int f,t;
void push(int xx,int yy){
que[t].x=xx;
que[t].y=yy;
t++;
}
struct data pop(){
... | 570 |
Project_CodeNet | 2,013 | h,w,c,S,max,C,N,r;
int *_M;
D(x,y){
_M[x+(w+2)*y]=N;
if(_M[x-1+(w+2)*y]==C)r++,D(x-1,y);
if(_M[x+1+(w+2)*y]==C)r++,D(x+1,y);
if(_M[x+(w+2)*(y-1)]==C)r++,D(x,y-1);
if(_M[x+(w+2)*(y+1)]==C)r++,D(x,y+1);
}
E(int d,int *M){if(d<4||M[1+w+2]!=c){
int *m=malloc(S);
if(d==4){
memcpy(_M=m,M,S);
C=m[1+w+2],N=c;D(1,1);... | 359 |
Project_CodeNet | 2,012 | #include<stdio.h>
#include<string.h>
#define max(a,b) (a>b?a:b)
int mv[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
int ori[10][10];
int map[10][10];
int fa[100];
int color[100];
int x,y,tar;
int find(int now){
if(fa[now]==-1)return now;
return fa[now] = find(fa[now]);
}
void chkun()
{
int i,j,k;
int dx,dy;
for(... | 657 |
Project_CodeNet | 2,015 | #include <stdio.h>
#define COLOR_NUM 6
/* パネル配置 */
typedef struct panel{
int h;
int w;
int p[8][8];
} Panel;
/* 変更履歴 */
typedef struct change_log{
int x[8*8];
int y[8*8];
int n;
int c;
} Log;
Panel p;
int c;
Log l[6];
int step;
/* パネルを表示する (デバッグ用) */
void show(){
int i, j;
for (i = 0; i < p.h; i++){
for ... | 1,095 |
Project_CodeNet | 2,012 | #include <stdio.h>
#include <string.h>
int h,w,c;
int map[6][8][8];
int visited[8][8];
void change_color(int stage,int x,int y,int src_color,int dist_color) {
if(x<0 || x>=w || y<0 || y>=h)return;
if(map[stage][y][x]!=src_color || src_color==dist_color)return;
map[stage][y][x]=dist_color;
change_color(stage,x-1,y... | 555 |
Project_CodeNet | 2,018 | #include <stdbool.h>
#include <stdio.h>
int h, w, c;
int memo[10][10] = {0};
bool added[10][10] = {0};
int stack[105][2] = {0};
int d[] = {1, 0, -1, 0};
int scnt;
void dfs(int col);
int solve(int now, int bf);
int max(int x, int y) { return x > y ? x : y; }
int main() {
int i, j;
while(1) {
scanf("%d %d %d",... | 616 |
Project_CodeNet | 2,014 | #include<stdio.h>
#include<string.h>
int P[8][8],H,W,C,i,j,mv[5]={0,-1,0,1,0};
int ch(int p[8][8],int h,int w,int c,int nc)
{
int i,nh,nw,res=0;
if(nc==-1)res++;
if(p[h][w]==c)
{
p[h][w]=nc;
for(i=0;i<4;i++)
{
nh=h+mv[i],nw=w+mv[i+1];
if(0<=nh&&0<=nw&&nh<H&&nw<W&&p[nh][nw]==c)
{
res+=ch(p,nh,nw,... | 420 |
Project_CodeNet | 2,016 | #include<stdio.h>
#define MAX 200
int p[6][MAX],stack[6][MAX],indexSTACK[6];
int h,w,c,max;
void STACKpush(int,int);
void colorChange(int,int);
void stackPanelR(int,int);
void stackPanel(int);
void panelR(int);
int panel();
int main(void){
int i;
while(1){
scanf("%d %d %d",&h,&w,&c);
if(h==0&&w==0&&c==0)b... | 679 |
Project_CodeNet | 2,020 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int map[6][8][8];
int h, w, c;
int max_count;
int visited[8][8];
#define fors(i, n) for (int i = 0; i < n; i++)
#define clean_visited fors(i, h) fors(j, w) visited[i][j] = 0
#define when_visited fors(i, h) fors(j, w) if (visited[i][j] == 1)
int parse()
{
s... | 658 |
Project_CodeNet | 2,016 | #include <stdio.h>
#define maxN 10
void dfs(int time, int color, int bfr[maxN][maxN]);
int changeColor(int bfr[maxN][maxN], int panel[maxN][maxN], int color, int x, int y);
int h, w, c, max;
int vx[] = {1,0,-1,0};
int vy[] = {0,1,0,-1};
int main(){
int i, j;
while(1){
int panel[maxN][maxN] = {};
scanf("%d %... | 555 |
Project_CodeNet | 2,016 | #include <stdio.h>
#define max(a, b) a<b?b:a
#define INF 1010001000
int board[10][10];
int copy[10][10];
int used[10][10];
int h, w, c, ans, ret;
void init(void);
void clused(void);
void dfs(int color, int x, int y);
void count(int color, int x, int y);
int main(void)
{
int i, j, k, l, m, n;
scanf("%d%d%d", ... | 938 |
Project_CodeNet | 2,017 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int max(int a,int b){
if(b>a)return b;
return a;
}
int p[10][10];
int cp[10][10];
int flag[10][10];
int h,w,c;
struct data{
int x,y;
};
struct data que[5000000];
int f,t;
void push(int xx,int yy){
que[t].x=xx;
que[t].y=yy;
t++;
}
struct data pop()... | 570 |
Project_CodeNet | 2,017 | import copy
import itertools
import sys
if sys.version[0] == '2':
range, input = xrange, raw_input
drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6
def dfs(r, c, now_c, next_c):
tmp_board[r][c] = next_c
for dr, dc in drc:
nr, nc = r + dr, c + dc
if 0 <= nr < H and 0 <= nc < W and tmp_b... | 370 |
Project_CodeNet | 2,019 | from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())
def dfs(x,y,s... | 409 |
Project_CodeNet | 2,019 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]... | 2,444 |
Project_CodeNet | 2,020 | from collections import deque
p_copy = []
def change(y):
global p_copy
x = p_copy[0][0]
que = deque()
que.append((0, 0))
memo = {(0, 0): 1}
while len(que) > 0:
i, j = que.popleft()
p_copy[i][j] = y
if i + 1 < h and p_copy[i + 1][j] == x and (i + 1, j) not in memo:
... | 810 |
Project_CodeNet | 2,015 | import sys,copy,itertools as it
sys.setrecursionlimit(10000)
dxy = zip([1,0,-1,0],[0,1,0,-1])
def check(A):
if A[0] == _P[0][0] or A[-1] != c: return False
for i in xrange(1,len(A)):
if A[i-1] == A[i]: return False
return True
def rec(x,y,b,c):
P[y][x] = c
for dx,dy in dxy:
nx,... | 305 |
Project_CodeNet | 2,018 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.... | 510 |
Project_CodeNet | 2,018 | direct = ((0, -1), (0, 1), (-1, 0), (1, 0))
def comb(target_color, mp, pos):
next_pos = pos[:]
end = len(next_pos)
ind = 0
while ind < end:
x, y = next_pos[ind]
for dx, dy in direct:
nx, ny = x + dx, y + dy
if mp[ny][nx] == target_color and (nx, ny) not in next_pos:
next_pos.append(... | 392 |
Project_CodeNet | 2,015 | ### constant
DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]
MAX_K = 5
MAX_C = 6
### subroutines
def count_area(flds)
return 0 if flds[0] != $c
used = $hw.times.map{false}
ar = 1
used[0] = true
q = [[0, 0]]
while ! q.empty?
x0, y0 = q.shift
DXYS.each do |dx, dy|
x1 = x0 + dx
y1 = y0 + dy... | 626 |
Project_CodeNet | 2,014 | $dx = [0,1,0,-1]
$dy = [1,0,-1,0]
def bfs(f, sy, sx, h, w, col)
q = [[sy,sx]]
visited = [[sy,sx]]
while q.size > 0
sy, sx = q.shift
for i in 0..3
cy = sy + $dy[i]
cx = sx + $dx[i]
if cy.between?(0,h-1) && cx.between?(0,w-1) && f[cy][cx]== f[sy][sx] && !vis... | 598 |
Project_CodeNet | 2,016 | require 'set'
def f(a, c, n, prev_group_size = 0)
g = group(a, 0, 0)
return g.size if n == 0
return g.size if g.size <= prev_group_size
max = 0
(n == 1 ? [c] : (1..6).to_a - [a[0][0]]).each do |k|
b = (0..a.size-1).map do |i|
(0..a[0].size-1).map do |j|
g.includ... | 393 |
Project_CodeNet | 2,016 | using System;
/*!!!GORIOSHI PROGRAM!!!*/
namespace V1174_1{
public class Program{
public static void Main(string[] args){
var sr = new StreamReader();
//---------------------------------
var dx = new[]{0, 1, 0, -1};
var dy = new[]{1, 0, -1, 0};
wh... | 949 |
Project_CodeNet | 2,019 | using System.Collections.Generic;
using System.Linq;
using static System.Math;
using System;
public class P
{
public int t { get; set; }
public int c { get; set; }
public string via { get; set; }
}
public class P2
{
public int x { get; set; }
public int y { get; set; }
}
public class Hello
{
... | 991 |
Project_CodeNet | 2,009 | #include <iostream>
#include <cstring>
#include <queue>
using namespace std;
bool h[16][16][16][16][10];
int dx[]={0,0,-1,0,1};
int dy[]={0,-1,0,1,0};
class Trl
{
public:
int bx,by,gx,gy,c;
Trl(int bx,int by,int gx,int gy,int c)
:bx(bx),by(by),gx(gx),gy(gy),c(c)
{}
};
int main()
{
int W,H,bx,by,gx,gy;
string ... | 654 |
Project_CodeNet | 2,009 | #include<iostream>
#include<vector>
#include<string>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;
typedef struct{
int ax,ay,bx,by,t;
}S;
bool operator<(const S &a,const S &b){
if(a.ax!=b.ax)return a.ax<b.ax;
if(a.ay!=b.ay)return a.ay<b.ay;
if(a.bx!=b.bx)re... | 660 |
Project_CodeNet | 2,009 | #include<iostream>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
int ans[2];
int dx[]={0,0,0,1,-1};
int dy[]={0,-1,1,0,0};
char m[16][16];
void setting(string &a,int *data){
rep(i,a.size()){
if ( a[i]=='5')data[i]=0;
... | 738 |
Project_CodeNet | 2,014 | // 2014Domestic G:Golf (pes)
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
const long long MAX_VALUE = 1LL<<36;
const long long MAX_DIGIT = 11;
vector< pair<int, long long> > power;
map<long long, int> term;
vector<long long> termV[... | 1,429 |
Project_CodeNet | 2,014 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll OF_MAX = (1LL<<36)-1;
const ll LEN_MAX = 11;
ll LENGTH[LEN_MAX+1];
inline ll mul(const ll &a, const ll &b){
if(!a || !b)return 0;
if( b > OF_MAX/a )return OF_MAX+1;
return a*b;
}
inline int len(const ll &a){
return upper_bound(LENGTH... | 1,851 |
Project_CodeNet | 2,019 | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif
using namespace std;
typedef long long... | 448 |
Project_CodeNet | 2,018 | #include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
using ll = long long int;
// const int S = 100000;
const int T = 1000010;
int prime[T+10], ans[T+10], rem[T+10];
int main() {
vector<int> primes;
for(int i=2; i<=T; i++) prime[i] = true;
for(int i=2; i<=T; i++) {
... | 377 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a... | 443 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define ... | 783 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
using namespace std;
const int vy[] = {0, 1, 0, -1}, vx[] = {1, 0, -1, 0};
int main()
{
bool prime[114515] = {};
int L, R;
cin >> L >> R;
int V[1145141], sum[1145141] = {};
for(int i = 0; i <= R - L; i++) V[i] = i + L;
prime[0] = true;
prime[1] = true;
for(int i = 2; i <... | 307 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
int main()
{
const int MAX = 1e6;
vector<bool> sv(MAX + 1, true);
sv[0] = sv[1] = false;
for (int i = 2; i <= MAX; i++) if (sv[i]) {
for (int j = i + i; j <= MAX; j += i) {
sv[j] = false;
}
}
int l, r;
cin >> l >> r; ++r;
vector<int> cnt(r - l), val(r - l);
... | 286 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
vector<Int> p,e(1e5);
e[0]=e[1]=1;
for(Int i=2;i<1e5;i++){
if(i*i>1e9) break;
if(e[i]) continue;
p.push_back(i);
for(Int j=i+i;j<(Int)e.size();j+=i) e[j]=1;
}
//cout<<p... | 326 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
vector<int>s;
bool use[1111111];
void MAKE(){
use[0]=use[1]=1;
for(int i=2;i<1111111;i++){
if(!use[i]){
for(int j=i+i;j<1111111;j+=i) use[j]=1;
}
}
r(i,1111111) if(!use[i]) s.push_back(i);
}
... | 345 |
Project_CodeNet | 2,018 | #include<iostream>
#include<algorithm>
using namespace std;
long l,r,lim=1<<20;
bool isp[1<<20],isplr[1<<20];
int now[1<<20],cnt[1<<20];
main()
{
cin>>l>>r;
isp[0]=isp[1]=1;
for(int i=l;i<=r;i++)now[i-l]=i;
for(long i=2;i<lim;i++)
{
if(isp[i])continue;
for(long j=i*2;j<lim;j+=i)isp[j]=1;
for(long j=(l+i-1)/i... | 206 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MXN = 1e6+5;
vector<int> p;
bool vis[MXN+5];
int L,R;
void sieve(){
vis[0] = 1;
vis[1] = 1;
for(int i=... | 361 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
ll l,r;
cin>>l>>r;
vector<bool> P(100000,true);
P[0]=P[1]=false;
for(ll i=2;i*i<100000;i++){
if(P[i]){
for(ll t=2;i*t<100000;t++){
P[i*t]=false;
}
}
}
vector<ll> count(r-l+1,0);
... | 287 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();
bool isp[401010];
bool isplr[1<<20];
int l, r;
vector<int> p;
void build(){
for(int i=0; i*i<=r; i++){
isp[i] = 1;
}
for(in... | 505 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=40005,INF=1<<30;
vector<int> prime;//i番目の素数
bool is_prime[MAX+1];
void sieve(int n){
int p=0;
for(int i=0;i<=n;i++){
is_prime[i]=true;
}
is_prime[0]=is_prim... | 374 |
Project_CodeNet | 2,019 | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int lim = 1e6;
vector<bool> p(lim, true);
p[0] = p[1] = false;
for(int i=2; i*i<lim; i++){
if(!p[i]) continue;
for(int j=i*2; j<lim; j+=i){
p[j] = false;
}
}
int l,r;... | 294 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef uns... | 713 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
ll l,r;
cin>>l>>r;
vector<bool> P(100000,true);
P[0]=P[1]=false;
for(ll i=2;i*i<100000;i++){
if(P[i]){
for(ll t=2;i*t<100000;t++){
P[i*t]=false;
}
}
}
vector<ll> count(r-l+1,0);
... | 287 |
Project_CodeNet | 2,020 | // #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
... | 837 |
Project_CodeNet | 2,020 | #define _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")
#include "bits/stdc++.h"
using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#defin... | 486 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,... | 993 |
Project_CodeNet | 2,017 | #include<bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool prime[50001];
int cnt[1000001];
ll l,r;
ll now[1000001];
int main(void){
memset(prime,true,sizeof(prime));
prime[0]=false;
prime[1]=false;
vector<int> p;
for(int i=2;i<=50000;i++){
if(prime[... | 356 |
Project_CodeNet | 2,018 | #include<iostream>
#include<string>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define min(a,b) (a>b?b:a)
#define max(a... | 677 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.