prompt string | response string |
|---|---|
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<cstdio>
using namespace std;
int main() {
int n, m, a, b, c, d, i, j, k, x[32][32];
cin >> n >> m;
for(i = 1; i <= n; i++)
for(j = 1; j <= n; j++)
x[i][j] = 1001001001; for(i = 0; i < m; i++) {
scanf("%d,%d,%d,%d", &a, &b, &c, &d);
x[a][b] = c;
x[b][a] = d;
}
for(k = 1; k <=... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <iostream>
#include <cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,x3,x4;
int main() {
scanf("%d%d", &N, &M);
int K[24][24];
for (int i=1; i<=N; i++){
for(int j=1; j<=N; j++){
K[i][j] = 1e6;
}
}
while(M) {
scanf("%d,%d,%d,%d", &A, &B, &C, &D);
K[A][B] = C;
K[B][A] =... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
using namespace std;
int mapData[21][21];
void init(int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
mapData[i][j] = 1001;
}
}
}
void solve(int n) {
for (int k = 1; k < n; k++) {
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
if (mapData[i... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include<iostream>
#include<vector>
using namespace std;
int main(void){
int n,m;
cin>>n>>m;
vector<vector<int> > t(n,vector<int>(n,1<<22));
int a,b,c,d;
char dm;
for(int i = 0 ; i < m ; i ++){
cin>>a>>dm>>b>>dm>>c>>dm>>d;
a--,b--;
t[a][b] = c;
t[b][a] = d;
}
int x1,x2,y1,y2;
cin... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
int ... |
Problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no such big pillar in the town. So the carpenter decided to go t... | //AOJ0117
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 1000000000
int n,m,r[21][21],cost[21][21];
int x1,x2,y1,y2;
int d[21];
int BF(int a,int b){
for(int i=0;i<21;i++)d[i]=INF;
d[a]=0;
for(int i=0;i<n-1;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | # AOJ 0254: Scone
# Python3 2018.6.25 bal4u
s = [0 for i in range(30001)]
while True:
n, m = map(int, input().split())
if n == 0: break
f = [-1 for i in range(m)]
sum, nmax, ans = 0, 0, 0
a = list(map(int, input().split()))
for i in range(n):
sum += a[i]
a[i] %= m
if a[i] > nmax: nmax = a[i]
if a[i] == m... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | def main():
while 1:
N, M = map(int, input().split())
if N == M == 0:
break
data = [0]*(M+1)
def add(k, x):
while k <= M:
data[k] += x
k += k & -k
def get(k):
s = 0
while k:
s += d... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int k[30001], s[30001];
int main()
{
while (scanf("%d %d", &n, &m), n){
set<int> T;
for (int i = 1; i <= n; i++){
scanf("%d", &k[i]);
k[i] %= m;
s[i] = (k[i] + s[i - 1]) % m;
}
int res = 0;
for (int i = 1; i <= n; i++){
res = max(res... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <random>
#include <cmath>
#include <climits>
#include <iomanip>
#include <cfloat>
#include <set>
int main() {
int n, m; std::cin >> n >> m;
while (n != 0) {
std::vector<long long int> scone(n... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n || m) {
set<int> s;
int sum = 0, res = 0;
s.insert(0);
for(int i = 0; i < n; i++) {
unsigned int a;
set<int>::iterator it;
cin >> a;
sum = (sum + a) % m;
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define int long long
#define REP(i,n) for(int i=0;i<(int)(n); ++i)
signed main() {
ios::sync_with_stdio(false);
while(true) {
int N, M; cin >> N >> M;
if(N == 0 && M == 0) break;
vector<int> K(N);
REP(i,N... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<vector>
#include<climits>
#include<algorithm>
const int INF = INT_MAX;
const int NIL = -1;
class RangeMinimumQuery {
public:
RangeMinimumQuery(int s) {
size_ = 1;
while(size_ < s) size_ <<= 1;
node_ = std::vector<int>((size_ << 1) - 1, INF);
}
int find(int left, int right) const {
return ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n, m;
while(cin >> n >> m, n != 0){
int num = 0;
int a[30010];
int b[30010];
multiset<int> st;
for(int i = 0;i < n;i++){
cin >> a[i];
num += a[i];
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <map>
#define int long long
using namespace std;
signed main(){
int n,m;
while(cin >> n >> m,n){
int a[30010] = {},ma = 0;
map<int,bool> mp;
for(int i = 1;i <= n;i++){
cin >> a[i];
a[i] = (a[i - 1] + a[i]) % m;
auto it = mp.upper_bound(a[i]);
if(it == mp.end()) ma = max... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(auto j: sum) {
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
Int n,m;
while(cin>>n>>m,n){
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(auto j: sum) {
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #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... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(auto j: sum) {
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(int j = 1; j < sum.si... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
struct SegNode
{
int v;
SegNode(int v) : v(v) {}
SegNode operator*(const SegNode &r) const
{
return (v > r.v ? *this : r);
}
} e(-(1 << 30));
struct SegmentTree
{
int sz;
vector< SegNode > seg;
SegmentTree(int n)
{
s... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
#define MAX_N 30005
int n;
int m;
int t[MAX_N];
int main(){
while(1){
cin>>n>>m;
if(n==0&&m==0)break;
for(int i=1;i<=n;i++){
scanf("%d",&t[i]);
t[i]=(t[i]%m+t[i-1])%m;
}
set<int> A;
set<int> :: iterator it;
int ans=0;
A.i... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)
int K[30000];
int func(int n, int m)
{
rep(... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n) {
vector<int> a(n+1);
for(int i=1; i<=n; ++i) {
cin >> a[i];
a[i] %= m;
(a[i] += a[i-1]) %= m;
}
int res = 0;
set<int> s;
for(int i=1;... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <set>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int N, M;
while (cin >> N >> M, N) {
set<int> s; int S = 0, mn = 1 << 30, ans = 0;
for (int i = 0; i <= N; ++i) {
long long X;
if (i >= 1) cin >> X;
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <stdio.h>
#include <set>
using namespace std;
int main(){
int n,m,now,ans;
set<int> s;
unsigned int temp;
while(true){
scanf("%d%d",&n,&m);
if(n==0&&m==0)return 0;
s.clear();
s.insert(m);
now=ans=0;
for(int i=0;i<n;i++){
scanf("%u",&te... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;
#define Seg_Max_N (1<<18)
using Value = pair<long long int, long long int>;
const Value ini = (make_pair(-1e9, 1e9));
struct segtree {
int N;
vecto... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int N, M;
vector<int> SconeData;
set<int> DpScone;
void solve() {
int sum, maxScone;
set<int>::iterator it;
sum = 0;
for (int i = 0; i < N; ++i) {
sum += SconeData[i] % M;
SconeData[i] = sum%M;
}
maxScone = 0;
for (int i = 0; i < N; ++i) {
it = DpScone.uppe... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll N, M, K;
while (cin >> N >> M, N) {
ll res = 0;
vector<ll> sum(N+1, 0);
for (int i = 0; i < N; i++) {
cin >> K;
sum[i+1] = (sum[i] + K) % M;
res = max(res, sum[i+1])... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
long long c[31000];
int d[31000];
int main(){
int a,b;
while(scanf("%d%d",&a,&b),a){
for(int i=0;i<a;i++)scanf("%lld",c+i);
long long now=0;
for(int i=0;i<a;i++){
now+=c[i];
d[i]=now%b;
}
set<int> S;
S.insert(b);
int ret=0;
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
//Segment Tree for Range Maximum Query
class SegmentTree{
int n;
vl node;
public:
SegmentTree(int n_){
n=1;
while(n<n_)n*=2;
node = vl(2*n-1,... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int main(){
int n,m;
while(cin >> n >> m, n|m ){
vector<int> arr(n);
rep(i,n) { cin >> arr[i]; arr[i] %= m; }
int maxi = 0;
rep(i,n) {
int sum = 0;
REP(j,i,n){
( s... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
set<int> used;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
used = {m};
int answer = 0;
for(auto j: sum) ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
const int MAX_N = 31000;
const int MAX_M = 100010;
int n,m,arr[MAX_N],mod_sum[MAX_N];
int bit[MAX_M];
int sum(int i) {
++i;
int s = 0;
while( i > 0 ){
s += bit[i];
i ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
const int MAX_N = 31000;
const int MAX_M = 100010;
int n,m,arr[MAX_N],mod_sum[MAX_N];
int bit[MAX_M];
int sum(int i) {
++i;
int s = 0;
while( i > 0 ){
s += bit[i];
i ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<iostream>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
int n, m;
while(cin >> n >> m, n+m){
ll k[n];
for(int i = 0; i < n; i++) cin >> k[i], k[i] %= m;
for(int i = 1; i < n; i++) k[i] = (k[i]+k[i-1])%m;
set<ll> s;
s.... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<iostream>
#include<set>
using namespace std;
int n,m;
int main()
{
while(cin>>n>>m,n)
{
set<long>S;
S.insert(0);
long sum=0,ans=0;
for(int i=0;i<n;i++)
{
long k;cin>>k;
sum=(sum+k)%m;
auto it=S.upper_bound(sum);
if(it==S.end())it=S.lower_bound(0);
int a=*it;
if(sum<a)ans=max(ans,m... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
#define MAX_N 30005
int n;
uint m;
uint t[MAX_N];
uint u[MAX_N];
int main(){
while(1){
cin>>n>>m;
if(n==0&&m==0)break;
for(int i=1;i<=n;i++){
scanf("%u",&t[i]);
t[i]%=m;
u[i]=(t[i]+u[i-1])%m;
}
set<uint> A;... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
while (cin >> n >> m, n || m) {
vector<ll> k(n);
for (int i = 0; i < n; ++i) {
cin >> k[i];
k[i] %= m;
}
vector<... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int N, M;
int pSeg[1 << 19];
void update(int k, int x)
{
k += (1 << 18) - 1;
pSeg[k] = x;
while (k){
k = (k - 1) / 2;
pSeg[k] = min(pSeg[k * 2 + 1], pSeg[k * 2 + 2]);
}
}
int getMin(int a, int b, int k, int l, int r)
{
if (b <... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, m ;
while( cin >> n >> m && n){
set<int> tot;
tot.insert(0);
tot.insert(m);
int sum = 0;
int answer = 0;
for(int i = 0 ; i < n ; i++){
int k; cin >> k;
sum = sum + k % m;
sum %= m;
answer = max( (sum-*tot.upper_bound(sum)+2*m)%m... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | from bisect import bisect_left as bl
while True:
n, m = map(int, input().split())
if n == 0:
break
klst = list(map(int, input().split()))
cum = []
acc = 0
for k in klst:
acc += k
acc %= m
cum.append(acc)
use = [0]
use_len = 1
ans = 0
for k in cum:
ind = bl(use, k + 1)
if ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <set>
using namespace std;
set<int> s[100000];
int main() {
int i,n,m,p,h,g,ans;
unsigned int d;
while (cin >> n >> m && n+m>0) {
ans=0; h=0;
for (i=0;i<m;i++) s[i].clear();
for (i=0;i<n;i++) { cin >> d; h=(h+(d % m)) % m; if (h>ans) ans=h; s[h].insert(i); if (i==0) ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n, m;
while(cin >> n >> m, n) {
vector<int> a(n+1);
for(int i=1; i<=n; ++i) {
cin >> a[i];
a[i] %= m;
(a[i] += a[i-1]) %= m;
}
int ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int n, m;
while (cin >> n >> m, n | m) {
vector<int> K(n), sum(n), rsum(n);
for (int i = 0; i < n; i++) {
ll tmp;
cin >> tmp;
K[i] = tmp % m;
}
sum[0] = K[0];
rsum[0] = (m - sum[0]) % m;
for (int i = 1; i < n; i++) ... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template<class T> constexpr... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
//Segment Tree for Range Maximum Query
class SegmentTree{
int n;
vl node;
public:
SegmentTree(int n_){
n=1;
while(n<n_)n*=2;
node = vl(2*n-1,... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> scone(n);
for(auto& i: scone) cin >> i;
vector<int> sum = {0};
for(auto i: scone) sum.push_back((sum.back() + (i % m)) % m);
int answer = 0;
set<int> used = {m};
for(int j = 1;... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(auto j: sum) {
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){
return o<<"("<<p.first<<","<<p.s... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll N,M,K;
while(cin >> N >> M, N){
vector<ll> sum(N+1,0);
for(int i = 0 ; i < N ; i++){
cin >> K;
sum[i+1] = (sum[i] + K) % M;
}
ll res = 0;
set<ll> st = {0};
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
long long x[30005];
int main() {
while(1){
int n,m; scanf("%d%d",&n,&m);
if(n+m==0) return 0;
for(int i=1;i<=n;i++){
long long a; scanf("%lld",&a);
x[i... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);
using namespace std;
namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(cons... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, m;
ll k[33333];
int main(void) {
for (;;) {
scanf("%d%d", &n, &m); if (n+m == 0) break;
for (int i = 0; i < n; i++) scanf("%lld", k+i);
set<long long> t;
t.insert(0);
long long s = 0;
... |
Problem: Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The baked scones are placed on a tray and lined up on the counte... | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n | m) {
vector<int> sum = {0};
for(int i = 0; i < n; ++i) {
int K;
cin >> K;
sum.push_back((sum.back() + (K % m)) % m);
}
int answer = 0;
set<int> used = {m};
for(auto j: sum) {
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<cstdio>
#include<stack>
#include<vector>
using namespace std;
vector<int> vec[101];
bool ch[101]={};
bool visited[101]={};
int dp[101]={};
int maxx = -1;
int maxNODE = -1;
void DFS(int i,int val){
if(val > maxx)maxx = val;
dp[i] = max(dp[i],val);
int len = vec[i].size();
for (int k=0; k<len... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<iostream>
#include<algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define z 100
using namespace std;
int n,a,b,q[z],l[z],la,be,an,ct[z],c[z][z];bool v[z],s[z];void d(int x,int len){if(len>be){la=x;be=len;}v[x]=1,s[x]=1;for(int i=0;i<ct[x];i++)if(!v[c[x][i]]){d(c[x][i],len+1);v[c[x][i]]=0;}}int main(){while(1){... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | //Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typede... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <bits/stdc++.h>
using namespace std;
vector<int> ls[100];
bool visited[100];
int dfs(int now,int l){
int ans=l;
visited[now]=true;
for(int i=0;i<(int)ls[now].size();i++){
if(visited[ls[now][i]]) continue;
ans=max(ans,dfs(ls[now][i],l+1));
}
visited[now]=false;
return ans;
}
int main(){
while(true){
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define z 100
using namespace std;
int n,a,b,la,be,an,ct[z],c[z][z];bool v[z],s[z];void d(int x,int len){if(len>be){la=x;be=len;}v[x]=1,s[x]=1;for(int i=0;i<ct[x];i++)if(!v[c[x][i]]){d(c[x][i],len+1);v[c[x][i]]=0;}}int main(){while(1){cin>>n;if(!n)break;r(i,z)... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#de... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <bits/stdc++.h>
using namespace std;
vector<int> G[101];
bool V[101]={};
bool Vis[101]={};
int DP[101] = {};
int N;
int Ans = 0;
void DFS(int n,int len){
Ans = max(Ans,len);
DP[n] = max(DP[n],len);
int S = G[n].size();
for(int i=0;i<S;i++){
if(!V[G[n][i]]){
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<bits/stdc++.h>
using namespace std;
int N;
vector<int>G[100];
bool used[100];
int dfs(int pos){
used[pos]=true;
int ret=0;
for(int i=0;i<G[pos].size();i++){
int to=G[pos][i];
if(used[to])continue;
ret=max(ret,dfs(to));
}
used[pos]=false;
return ret+1;
}
void... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <cstdio>
#include <vector>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
vector<int> e[100];
bool used[100];
int ans;
void dfs(int x, int y){
if(used[x]){
if(y > ans) ans = y;
return;
}
used[x] = true;
rep(i,e[x].size()){
//if(used[e[x][i]]) ... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int> > edge;
int visited[128];
int n;
int depth = 0;
int solve(int k) {
if(visited[k])
return -1;
visited[k] = 1;
int res = -1;
for(int i = 0; i < edge[k].size(); i++) {
res = max(res, solve(edge[k][i]));
}
visited... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include "stdio.h"
#include <vector>
using namespace std;
vector<int> miti[100];
int mflg[100];
int saiki(int a)
{
if(mflg[a] != 0)
{
return 0;
}
int max = 0;
mflg[a] = 1;
for(int i = 0; i < miti[a].size(); i++)
{
int w = saiki(miti[a][i]);
if(max < w)
{
max = w;
}
}
mflg[a] = 0;
return max +... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<complex>
#include<cmath>
using namespace std;
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
const int N = 111;
vector<int> edge[N];
int visit[N]... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... |
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static PrintWriter out = new PrintWriter(System.out);
static Scanner sc = new Scanner(System.in);
static int INF = 2 << 20;
static Node[] node;
public static void main(String[] args) {
while(true) {
int n = ... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n;
vector<int> e[111];
bool f[111];
int solve(int m){
int ret = 0;
for(int i = 0; i < (int)e[m].size(); i++){
if(f[e[m][i]]) continue;
f[e[m][i]] = true;
ret = max(ret,solve(e[m][i])... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #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... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
//String With Rings
public class Main{
List<Integer>[] e;
int res;
boolean[] v;
void dfs(int k, int d){
res = Math.max(res, d);
for(i... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <vector>
using namespace std;
namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define VV(T) vector<vector... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
vector<vector<... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
int N;
vector<int> G[102];
int f[102];
int f2[102];
int search(int id){
int ret=0;
for(int i=0;i<(int)G[id].size();i++){
if(!f2[G[id][i]]){
f[G[id][i]]=1;
f2[G[id][i]]=1;
ret = max(ret,... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#defi... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
//String With Rings
public class Main{
List<Integer>[] e;
int res;
boolean[] v;
void dfs(int k, int d){
res = Math.max(res, d);
for(int x:e[k])if(!v[x]){
v[x] = true;
dfs(x, d... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<iostream>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int ans;
void dfs(vector<vector<int> >& G,int p,int cost,bitset<101>& visited)
{
bool update = false;
for(int i=0;i<G[p].size();i++)
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | //05
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> v[101];
bool p[101];
int dfs(int x){
if(p[x]){
return 0;
}else{
p[x]=true;
int m=0;
for(int i=0;i<v[x].size();i++){
m=max(m,dfs(v[x][i]));
}
p[x]=false;
return m+1;
}
}
int main(){
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
//int node[101][101];
int visit[101];
int ans,last;
int die[101];
int flag;
void dfs(int now, int cnt, int *st, vector<vector<int> >& vv){
if( cnt>ans ){
ans=cnt;
last = now;
flag = 1;
}
for(int next=0; next<vv[now].... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
typedef vector<int> vi;
vi G[100];
bool memo[101];
int func(int s, int n) {
int ret = n;
if(memo[s]) return ret;
memo[s] = true;
rep(i, G[s].size()) {
ret = max(ret, func(G[... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[100];
bool used[100];
int dfs(int now){
int res = 0;
used[now] = true;
for(auto &nxt : g[now]){
if(!used[nxt]){
res = max(res, dfs(nxt));
}
}
used[now] = false;
return res+1;
}
int main(){
while... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
vector<vector<int> > G(100);
typedef bitset<100> bs;
map<bs, int> dp;
namespace std {
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespac... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <bits/stdc++.h>
using namespace std;
int dfs (vector<vector<int> > &v, int now, vector<bool> &used, int count) {
if (used[now]) return count;
count++;
used[now] = true;
int ret = count;
for (auto i : v[now]) {
ret = max(ret, dfs(v, i, used, count));
}
used[now] = false;
... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <iostream>
#include <set>
#include <cstring>
using namespace std;
int node[101][101];
int visit[101];
int ans,last;
int die[101];
int flag;
void dfs(int now, int cnt, int *st){
if( cnt>ans ){
ans=cnt;
last = now;
flag = 1;
}
for(int next=0; next<101; next++)if( node[now][next] && !visit[next] ){
v... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int ans;
vector<int> edge[100];
bool flg[100] ={};
void dfs(int v, int d){
ans = max(ans, d);
flg[v] = true;
for(int i=0; i<edge[v].size(); i++){
if(!flg[edge[v][i]]) dfs(edge[v][i], d+1);
}
flg[v] = fals... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> edge[100];
bool visit[100];
int solve(int n) {
int mx=1;
visit[n]=1;
for(int i=0;i<edge[n].size();i++) {
if(!visit[edge[n][i]]) {
mx=max(mx,solve(edge[n][i])+1);
}
}
visit[n]=0;
return mx;
}
int main() {
int n;
whil... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int v[100];
vector<int> g[100];
inline int dfs(int x){
int ans = 0;
for(int i = 0,l = g[x].size(); i < l; i++){
int y = g[x][i];
v[x]++;
if(!v[y]){
ans = max(ans,dfs(y)+1);
}
v[x]--;
}
return ans;
}
int main(){
int n;
w... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | // tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typede... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long int64;
int dfs(int v, vector<vector<int> > &g, ve... |
Problem: Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of one string and the other string is the same, these strings ... | #include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> g[101];
bool use[101];
int n;
int dfs(int x,int k){
int res = 0;
use[x] = true;
for(int i=0;i<(int)g[x].size();i++){
if(!use[g[x][i]])res = max(res,dfs(g[x][i],k-1));
if(res+1==k)break;
}
use[x] = false;
return ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.