Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#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 ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int,int> pint; string p[9],m[9]; bool used[9]; int dfs(int cnt){ int ret=0; if(cnt==9) return 1; rep(i,9){ ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include <bits/stdc++.h> using namespace std; char p[3][3][4]; char pz[9][4]; 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; ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include <iostream> #include <algorithm> #include <cctype> #include <cstring> 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; /* for(int i=0; i<9; i++) { cout <<...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
import java.util.*; public class Main { final int INF = 1 << 24; 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 void d...
JAVA
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#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 cnt = 0; void dfs(int p) { 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 ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include <iostream> #include <string> #include <vector> #include <cctype> using namespace std; int recur(const vector<string> &pieces, int used, const char *conn){ int index = __builtin_popcount(used); if(index >= 9){ return 1; } int x = index % 3, y = index / 3; char nextConn[5] = { conn[0], conn[1], conn[2], co...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include<cstdio> #include<algorithm> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; char piece[9][5]; char put[3][3][4]; bool match(char a,char b){ return a-b=='a'-'A' || a-b=='A'-'a'; } int dfs(int y,int x,bool *used){ if(y==3) return 1; if(x==3) return ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include<iostream> #include<string> #include<algorithm> #include<cctype> #define MAX 9 using namespace std; char ChangeCase(char c){ if( islower( c ) ) return toupper( c ); else if( isupper( c ) ) return tolower( c ); else return '\0'; } struct piece{ char c[4]; }; struct puzzle{ piece pieces[MAX][4]; bool ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#include<iostream> #include<sstream> #include<vector> #include<set> #include<map> #include<queue> #include<algorithm> #include<numeric> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #define rep(i,n) for(int i=0;i<n;i++) #define all(c) (c).begin(),(c).end() #define mp make_pair ...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
#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,...
CPP
p00697 Jigsaw Puzzles for Computers
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, "Jigsaw pu...
7
0
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new aoj1116().doIt(); } class aoj1116{ int result = 0; char map[][] = new char [9][4]; boolean check[] = n...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> #include <unordered_map> using namespace std; using VS = vector<string>; using LL = long long; using VI = vector<int>; using VVI = vector<VI>; using PII = pair<int, int>; using PLL = pair<LL, LL>; using VL = vector<LL>; using VVL = vector<VL>; #define ALL(a) begin((a)),end(...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> using namespace std; struct dice{ int x[6]; void roll_x(){roll(0,4,5,1);} void roll_y(){roll(0,2,5,3);} void roll_z(){roll(1,3,4,2);} vector<dice> all_rolls(){ vector<dice> res; for(int k=0; k<6; (k&1 ? roll_y() : roll_x()), k++){ for(int i=0; i<4; roll_z(),i++){ ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import java.util.*; public class Main { //0418 start //0503 cording end //0515 find a fatal error and sleep //1210 restart //1300 sample match WA //1320 WA modi {x,x,y,y}patttern //dice is, 0 = south, 1 = east, 2 = top, 3 = bottom, 4 = west, 5 = north; String [] order = {"","n","s", "e", "w", "nn"}; private ...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import java.util.*; public class Main { String [] order = {"","n","s", "e", "w", "nn"}; String [] orderrev = {"","s","n", "w", "e", "nn"}; int n, ans; Dice [] d; class Dice{ //dice is, 0 = south, 1 = east, 2 = top, 3 = bottom, 4 = west, 5 = north; int [] dice; public Dice(int[] dice) { this.dice = dice...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; //Colored Cubes public class Main{ public static class Dice <T>{ public T[] id; enum Face{TOP, BOTTOM, FRONT, BACK, RIGHT, LEFT}; public T get(int k){ return id[k]; } public ...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<cstdio> #include<cassert> #include<climits> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define IINF (INT_MAX) using namespace std; // Library - cycoro - begin -7:26 enum FACE {TOP,BOTTOM,FRONT,BACK,LEFT,RIGHT...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import copy # 回転方法の全列挙 def turn(box): turnlist = [] for j in range(4): for i in range(4): turnlist.append(box) box = [box[0], box[3], box[1], box[4], box[2], box[5]] box = [box[3], box[1], box[0], box[5], box[4], box[2]] box = [box[1], box[5], box[2], box[3], box[0],...
PYTHON3
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<numeric> #include<map> #include<algorithm> using namespace std; #define REP(i,b,n) for(int i=b;i<n;i++) #define rep(i,n) REP(i,0,n) #define rotate_swap(x,a,b,c,d) swap(x.a,x.b);swap(x.b,x.c);swap(x.c,x.d); class Dice{ public: int top,front,right,left,back,bottom; }; void rotate_r(Di...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <utility> using namespace std; int n; int ans; int sz; vector<vector<int> > dices; int count(){ int ret = 0; for(int j = 1; j <= 6; ++j){ vector<int> c(sz); for(int i = 0; i < n; ++i){ ++c[ dices[i][j] ]; ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import java.util.*; public class Main { //0418 start //0503 cording end //0515 find a fatal error and sleep //1210 restart //1300 sample match WA //1320 WA modi {x,x,y,y}patttern //dice is, 0 = south, 1 = east, 2 = top, 3 = bottom, 4 = west, 5 = north; String [] order = {"","n","s"...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<map> #include<string> #include<iostream> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; struct cube{ int a[6]; cube(){ rep(i,6) a[i]=i; } void rotx(){ int tmp=a[0]; a[0]=a[2]; a[2]=a[5]; a[5]=a[4]; a[4]=tmp; } void roty(){ int tmp=a[0]; a[0]=a[1]; a[1]=a[5]; a[5]=a[3]; ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<cstdio> #include<cassert> #include<climits> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define IINF (INT_MAX) using namespace std; // Library - cycoro - begin -7:26 enum FACE {TOP,BOTTOM,FRONT,BACK,LEFT,RIGHT}; ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <iostream> #include <cstdio> #include <cstring> #include <map> #include <algorithm> #define FOR(i,l,r) for (i=l;i<=r;i++) #define INF 0x3f3f3f3f using namespace std; int i,j,k,l,m,n; static int c[5][6],t[30],z[6]; const int w[24][6]={2,3,0,5,4,1, 3,2,0,5,1,4, 4,1,0,5,3,2, 1,4,0,5,2,3, 2,3,1,4,0,5, 3,2,1,4,5...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<algorithm> #include<string> #include<map> #include<vector> #include<complex> #include<sstream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cctype> #include<cstring> using namespace std; #define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++) #define rep(i,n) REP(i, 0, n) s...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> using namespace std; class Dice{ private: int tmp; public: int d[6]; void rollN(){ tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; } void rollE(){ tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; } void rotati...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
// Colored Cubes // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1259 #include<iostream> #include<map> #include<vector> #include<algorithm> #include<cmath> #include<climits> #include<ctime> #include<cstring> #include<numeric> #include<functional> #define ALL(v) (v).begin(),(v).end() #define REP(i,p,n) f...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <iostream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <map> #include <algorithm> #include <set> #include <sstream> #include <numeric> #include <bitset> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <clim...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
/************************************************************************* > File Name: c.cpp > Author: X__X > Mail: Kinderlas@gmail.com > Created Time: 2012/8/12 14:35:54 ************************************************************************/ #include<cstdio> #include<cstring> #include<cstdlib> #include<i...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
//03 #include<iostream> #include<string> #include<algorithm> using namespace std; int n; string d[4][6]; void rot(int x,string *d){ int r[][4]={{0,1,5,4},{0,2,5,3},{1,3,4,2}}; string t=d[r[x][0]]; d[r[x][0]]=d[r[x][1]]; d[r[x][1]]=d[r[x][2]]; d[r[x][2]]=d[r[x][3]]; d[r[x][3]]=t; } int dfs(int r){ if(r...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
import java.util.*; import java.lang.*; import java.math.*; public class Main { Scanner sc = new Scanner(System.in); // int[][] map = { { 0, 1, 2, 4, 3, 5 }, { 0, 2, 4, 3, 1, 5 }, // { 0, 4, 3, 1, 2, 5 }, { 0, 3, 1, 2, 4, 5 }, // // { 1, 2, 0, 3, 5, 4 }, { 1, 5, 2, 0, 3, 4 }, { 1, 3, 5, 2, 0, 4 }, // { 1, 5, ...
JAVA
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <cstdio> #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 ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <array> #include <climits> #include <iostream> #include <unordered_map> #include <vector> using namespace std; template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; } template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; } enum FACE {SOUTH, EAST, TOP, BOTTOM, WEST, NORT...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#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> using namespace std; #define FOR(i,k,n) for(int i=(k); i<(int)(n);...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<string> #include<map> 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 yn(f) (f?"Yes":"No") #define YN(f) (f?"YES":"NO") #define pro "はいプロ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> using namespace std; enum FACE { BACK, RIGHT, TOP, BOTTOM, LEFT, FRONT }; template <class T> class Dice { public: Dice() { id[TOP] = 2; id[FRONT] = 5; id[LEFT] = 4; id[RIGHT] = 1; id[BACK] = 0; id[BOTTOM] = 3; } ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <cstdio> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <cstring> #include <sstream> using namespace std; #define...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
def solve(): from itertools import product from sys import stdin f_i = stdin # idices of faces indices = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 4, 3, 2, 1, 5), (0, 3, 1, 4, 2, 5), (1, 0, 3, 2, 5, 4), (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (1, 2, 0...
PYTHON3
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b)a=b;}; template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b)a=b;}; struct Dice{ Int s[6]; void roll(char c){ Int b; if(c == 'E'){ b = s[0]; s[0] = s[3...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <stdio.h> #include <cmath> #include <algorithm> #include <cfloat> #include <stack> #include <queue> #include <vector> #include <string> #include <iostream> #include <set> #include <map> #include <time.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 100000...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <cstdio> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <cstring> #include <sstream> using namespace std; #define...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> using namespace std; class Dice{ public: int TOP = 2, FRONT = 0, LEFT = 4, RIGHT = 1, BACK = 5, BOTTOM = 3; vector<int> val; Dice():val(6){for(int i=0;i<6;i++) val[i] = i;} Dice(int val[6]){for(int i=0;i<6;i++) this->val[i] = val[i];} Dice(vector<int> val):val(val){assert(val.size...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<stdio.h> #include<string> #include<algorithm> #include<vector> using namespace std; int dice[6][6]={ {0,1,2,4,3,5}, {2,0,1,5,4,3}, {1,2,0,3,5,4}, {4,5,3,0,2,1}, {5,3,4,2,1,0}, {3,4,5,1,0,2}, }; int q[4]; string str[4][6]; char in[30]; int main(){ int a; while(scanf("%d",&a),a){ for(int i=0;i<a;i++)for(int ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <cstdio> #include <cstring> #include <string> #include <map> #include <iostream> using namespace std; const int mov[24][6]= { {0,1,2,3,4,5},{0,2,4,1,3,5},{0,4,3,2,1,5},{0,3,1,4,2,5}, {3,1,0,5,4,2},{3,0,4,1,5,2},{3,4,5,0,1,2},{3,5,1,4,0,2}, {5,1,3,2,4,0},{5,3,4,1,2,0},{5,4,2,3,1,0},{5,2,1,4,3,0}, {2,1...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
int dice24[24][6]= { {2,1,5,0,4,3},{2,0,1,4,5,3},{2,4,0,5,1,3},{2,5,4,1,0,3},{4,2,5,0,3,1}, {5,2,1,4,3,0},{1,2,0,5,3,4},{0,2,4,1,3,5},{0,1,2,3,4,5},{4,0,2,3,5,1}, {5,4,2,3,1,0},{1,5,2,3,0,4},{5,1,3,2,4,0},{1,0,3,2,5,4},{0,4,3,2,1,5}, {4,5,3,2,0,1},{1,3,5,0,2,4},{0,3,1,4,2,5},{4,3,0,5,2,1},{5,3,4,1,2,0}, {3,4,5,0,1...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> using namespace std; enum {TOP=0,FRONT,RIGHT,LEFT,BACK,BOTTOM}; #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rotate_swap(x,a,b,c,d) swap(x.m[a],x.m[b]);swap(x.m[b],x.m[c]);swap(x.m[c],x.m[d]); class Dice{ publ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> using namespace std; #define dump(a) (cerr << #a << " = " << (a) << endl) #define REP(i,a,b) for(int i=(a);i < (int)(b); i++) #define rep(i,n) REP(i,0,n) #define ALL(v) begin(v), end(v) enum FACE {SOUTH, EAST, TOP, BOTTOM, WEST, NORTH}; typedef array<int, 6> A; struct dice { A value; ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
def rotateX(dice): d1, d2, d3, d4, d5, d6 = dice return [d2, d6, d3, d4, d1, d5] def rotateY(dice): d1, d2, d3, d4, d5, d6 = dice return [d4, d2, d1, d6, d5, d3] def rotateZ(dice): d1, d2, d3, d4, d5, d6 = dice return [d1, d3, d5, d2, d4, d6] def check(): global n, s_count diff = [...
PYTHON3
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <array> #include <climits> #include <iostream> #include <unordered_map> #include <vector> using namespace std; template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; } enum FACE {SOUTH, EAST, TOP, BOTTOM, WEST, NORTH}; typedef array<int, 6> A; struct dice { A value; dice(const A &v...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <algorithm> #include <vector> #include <cfloat> #include <string> #include <cmath> #include <set> #include <cstdlib> #include <map> #include <ctime> #include <iomanip> #include <functional> #include <deque> #include <iostream> #include <cstring> #include <queue> #include <cstdio> #include <stack> #include <cli...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<algorithm> #include<bitset> #include<cctype> #include<cmath> #include<complex> #include<cstdio> #include<cstring> #include<iostream> #include<map> #include<numeric> #include<queue> #include<set> #include<sstream> #include<stack> #include<string> #include<vector> #define repi(i,a,b) for(int i = int(a); i < int...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<bits/stdc++.h> #define ll long long #define lp(i, n) for(int i=0;i<(n);++i) #define per(i, n) for(int i=(n)-1;i>=0;--i) #define lps(i, n) for(int i=1;i<(n);++i) #define foreach(i, n) for(auto &i:(n)) #define pii pair<int, int> #define pll pair<long long, long long> #define all(x) (x).begin(), (x).end() #define...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include<iostream> #include<map> #include<algorithm> #include<vector> using namespace std; struct die{ int t[6]; void ra(){ int tmp=t[0]; t[0]=t[2]; t[2]=t[5]; t[5]=t[3]; t[3]=tmp; } void rb(){ int tmp=t[1]; t[1]=t[2]; t[2]=t[4]; t[4]=t[3]; t[3]=tmp; } void rc(){ ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
def solve(): from itertools import product from sys import stdin f_i = stdin # idices of faces indices = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 4, 3, 2, 1, 5), (0, 3, 1, 4, 2, 5), (1, 0, 3, 2, 5, 4), (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (1, ...
PYTHON3
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <cassert> #include <queue> #include <set> #include <map> #include <valarray> #include <bitset> #include <stack> using namespace std; #define ...
CPP
p00838 Colored Cubes
There are several colored cubes. All of them are of the same size but they may be colored differently. Each face of these cubes has a single color. Colors of distinct faces of a cube may or may not be the same. Two cubes are said to be identically colored if some suitable rotations of one of the cubes give identical l...
7
0
#include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; struct Dice{ int s[6]; void roll(char c){ int b; if(c=='S'){ b=s[0]; s[0]=s[4]; s[4]=s[5]; s[5]=s[1]; s[1]=b; } if(c=='E'){ b=s[0]; s[0]=s[3]; s[3]=s[5]; s[5]=s[2...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define rep(i,n) for(int i=0;i<n;i++) #define repn(i,n) for(int i=1;i<=n;i++) #define fi first #define sc second vector<int>vec; int n,m,x; int main(){ cin >> n >> m >> x; rep(i,x){ int a,b; cin >> a >> b; a = n+1-a; if(b <=...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> #define REP(i,n) for (int i = 0; (i) < (n); ++(i)) #define REP3(i,m,n) for (int i = (m); (i) < (n); ++(i)) #define ALL(x) begin(x), end(x) using namespace std; using ll = long long; int solve(int h, int w, int p, vector<int> const & y, vector<int> const & x) { vector<int> t(p); REP (i,...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#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; int num_row,col_half,N; int main(){ scanf("%d %d %d",&num_row,&col_half,&N); int goal_row = num_r...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
//#define _GLIBCXX_DEBUG #include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define P pair<ll,ll> #define FOR(i,n,m) for(ll i=n; i<(ll)m;i++) #define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--) #define FORm(i,m) for(auto i=m.begin();i!=m.end();i++) #define sort...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; int main() { int r, s, p; cin >> r >> s >> p; vi ds; while (p--) { int i, j; cin >> i >> j; i--, j--; if (j >= s) { j++; } int d = abs(r - i) + abs(...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> using namespace std; ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) using ll = long long; ll r,s,p; vector<ll> y,x,d; signed main() { cin >> r >> s >> p; y.resize(p);x.resize(p); rep(i,p) cin >> y[i] >> x[i]; d.resize(p); rep(i,p) { d[i] = abs(x[i] ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int r, s, p; cin >> r >> s >> p; vector<int> ds; for (int _ = 0; _ < p; _++) { int i, j; cin >> i >> j; int d = abs(r - i) + 1; d += j <= s ? s - j + 1 : j - s; ds.emplace_back(d); ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) { int r = in.nextInt(), s = in.nextInt(), p = in.nextInt(); int[] d = new int[p]; ...
JAVA
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std; int main() { int r, s, p, result = 0; vector<int> exitOrders; // 出られるまでの移動+待機の時間 cin >> r >> s >> p; for (int i = 0; i < p; i++) { int x, y; cin >> y >> x; exitOrders.push_back((r - y + 1) + (abs(s - x) + (x <= s ? ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include "bits/stdc++.h" #pragma warning(disable:4996) using namespace std; namespace cent { struct Edge { int src; int dst; //long long int cost; }; using Graph = vector<vector<Edge>>; class Centroid { private: int dfs(const Graph&g, const int now, const int from, vector<int>&ch_nums) { int sum = 1;...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int, int> #define nyan "(=^・ω・^=)" #define read_input freopen("in.txt","r", stdin) #define print_output freopen("out.txt","w", stdout) typedef long long ll; typedef long double ld; using namespace std; int main() { in...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> typedef long long ll; #define REP(i,n) for(int i = 0;i < (n);i++) #define rep(i,m,n) for(int i = (m);i < (n);i++) #define P pair<int,int> #define pb push_back #define mk make_pair using namespace std; #define Vec(a) vector <int> a #define F first #define S second const int INF = 1 << 20; const i...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include "bits/stdc++.h" using namespace std; int MAX_N = 10000000; vector<int> cnt(MAX_N, 0); int main() { int r, s, p; cin >> r >> s >> p; for (int i = 0; i < p; i++) { int x, y; cin >> x >> y; int sum = r + 1 - x; if (y <= s) { sum += s + 1 - y; } else { sum += y - s; } ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << end...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define int long long constexpr int INF = 1LL << 60; constexpr int MAX_P = 500005; constexpr int MAX_S = 505; constexpr int MAX_IMOS = MAX_P + 2 * MAX_S; typedef pair<int, int> pii; int r, s, p, imos[MAX_IMOS]; signed main() { ios::sync_with_stdio(false); cin...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1); #define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++) #define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long lo...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <algorithm> #include <functional> using namespace std; int r, s, p; int y[500000], x[500000]; int dist[500000]; int main() { int i; cin >> r >> s >> p; for (i = 0; i < p; i++) { cin >> y[i] >> x[i]; } for (i = 0; i < p; i++) { int distY = r + ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<double,double> #define ppap pair<pa,int> #define PI 3.14159265358979323846 #define paa pair<int,char> #define mp make...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define ALL(a) (a).begin(),(a).end() #define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl; #define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl; t...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int r, s, p; cin >> r >> s >> p; vector<int> nums; for (int _ = 0; _ < p; ++_) { int i, j; cin >> i >> j; --i, --j; if (j >= s) ++j; nums.push_back(abs(i - r) + abs(j - s)); } sort(n...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #def...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> #define MOD 1000000007 typedef long long ll; using namespace std; int main(){ int R,S,P; cin>>R>>S>>P; vector<int> X(P),Y(P); for(int i=0;i<P;i++) cin>>X[i]>>Y[i]; vector<int> v; for(int i=0;i<P;i++){ int cost=R-X[i]; if(Y[i]<=S) cost+=S-Y[i]+1; else cost+=Y[i]-(S+1)+1...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int r,s,p; cin >> r >> s >> p; vector<int> v; for (int i = 0; i < p; i++) { int a,b; cin >> a >> b; v.push_back(abs(b - s) + (b <= s) + r - a + 1); } int pp = 0; sort(v.begin(),v.end());...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { int r, s, p; cin >> r >> s >> p; vector<int> d(p); for(int k=0;k<p;k++) { int i, j; cin >> i >> j; d[k] = (r - i + 1); if(j <= s) { d[k] += s - j + 1; }else { d[k] += j - (s + 1) + 1; } } sort(d.begin(), d.end());...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int h,w,n,A[700000],x,y; int main(){ cin>>h>>w>>n; r(i,n){ cin>>y>>x; if(x>w)x++; A[i] = (h-y+1) + abs(x-(w+1)); } sort(A,A+n); r(i,n-1){ A[i+1] = max(A[i+1],A[i]+1); } cout<<A[n-1]<<endl; }
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int R,C,P; cin >> R >> C >> P; vector<int> v(P); for(int i=0;i<P;i++){ int x,y; cin >> x >> y; v[i] = {R-x+1+(y<=C? C-y+1:y-C)}; } sort(v.begin(),v.end(),greater<int>()); int ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(){ ios_base::sync_with_stdio(false); int r, s, n; cin >> r >> s >> n; vector<int> a; for(int i = 0; i < n; ++i){ int y, x; cin >> y >> x; --y; --x; int d = r - y; if(x < s){ d += s - 1 - x; }...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define TemplateVersion "3.4.1" // Useful Marcos //====================START===================== // Compile use C++11 and above #ifdef LOCAL #define debug(args...) \ { \ string _s = #args; ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#!/usr/bin/python3 import array from fractions import Fraction import functools import itertools import math import os import sys def main(): R, S, P = read_ints() A = [] for _ in range(P): i, j = read_ints() i -= 1 j -= 1 A.append((i, j)) print(solve(R, S, P, A)) d...
PYTHON3
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef unsigned long long ull; const long long INF=1e18; typedef pair<ll,ll> pll; #define F first #define S second int main(){ ll r,s,p; cin>>r>>s>>p; vector<ll> A(p); for(int i=0;i<p;i++){ ll x,y; cin>>x>>y; ...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<iostream> #include<iomanip> #include<cmath> #include<cstdlib> #include<cstring> #include<string> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<numeric> #include<limits> #include<map> using namespace std; #define rep(i,s,n) for(int i=s;i<n;i++) #define dow(i,n,s) for(int i=n-1;i...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int r, s, p; cin >> r >> s >> p; vector<int> nums; for (int _ = 0; _ < p; ++_) { int i, j; cin >> i >> j; --i, --j; if (j >= s) ++j; nums.push_back(abs(i - r) + abs(j - s)); } sort(n...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
r, s, p = map(int, input().split()) ps = [None] * p for k in range(p): i, j = map(int, input().split()) if j <= s: j -= 1 ps[k] = r + 1 - i + abs(s - j) ans = 0 for t, p in enumerate(sorted(ps)[::-1]): ans = max(ans, t + p) print(ans)
PYTHON3
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i)) using ll = long long; using P = pair<int, int>; using namespace std; int main() { int r, s, p; cin >> r >> s >> p; map<int, int> mp; rep(i, p) { int x, y; cin >> y >> x; if (x > s...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < (N); i++) #define all(a) (a).begin(), (a).end() #define pb push_back using ll = long long; using i_i = tuple<int, int>; int main() { int N, M, K; cin >> N >> M >> K; vector<int> a(1000000); while (K--) { int i...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}; template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}; signed main(){ cin.tie(0); ios::sync_with_stdio(false); Int r,s,n; cin>>r>>s>>n; vector<Int> y...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int inf = 1e9; int main(){ int r,s,p; cin >> r >> s >> p; vector<vector<int> > rinfo(r); for(int i=0; i<p; i++){ int y,x; cin >> y >> x; y--; x--; rinfo[y].push_back((x<s)?s-x-1:x-s); } for(int i=0; i<r; i++){ sort(ri...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#define _CRT_SECURE_NO_WARNINGS #include"bits/stdc++.h" #ifdef _DEBUG #define DBG(n) n #else #define DBG(n) #endif #define INF 1e9 #define INFLL 1e18 #define EPS 1e-9 #define REP(i,n) for(ll i=0,i##_len=(n);i<i##_len;++i) #define REP1(i,n) for(ll i=1,i##_len=(n);i<=i##_len;++i) #define R...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include<bits/stdc++.h> using namespace std; int dep[1010]; int n,m,p; int main(){ memset(dep,0,sizeof(dep)); scanf("%d%d%d",&n,&m,&p); int x,y,ex; while(p--){ scanf("%d%d",&x,&y); ex = n-x+1+abs(y-m); if (y<=m){ ex++; } dep[ex]++; } int ans=0...
CPP
p00970 Emergency Evacuation
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
7
0
#include <bits/stdc++.h> using namespace std; int main() { int r, s, p; cin >> r >> s >> p; vector<int> d(p); for(int i=0;i<p;i++){ int a, b; cin >> a >> b; d[i] = r-a+1 + (b<=s ? s+1-b : b-s); } sort(d.begin(), d.end()); int ans = 0; for(int i=0;i<p;i++){ ...
CPP