prob_desc_description
stringlengths
63
3.8k
prob_desc_output_spec
stringlengths
17
1.47k
lang_cluster
stringclasses
2 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
lang
stringclasses
7 values
prob_desc_output_to
stringclasses
3 values
prob_desc_memory_limit
stringclasses
19 values
file_name
stringclasses
111 values
tags
listlengths
0
11
prob_desc_created_at
stringlengths
10
10
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_notes
stringlengths
4
3k
exec_outcome
stringclasses
1 value
difficulty
int64
-1
3.5k
prob_desc_input_from
stringclasses
3 values
prob_desc_time_limit
stringclasses
27 values
prob_desc_input_spec
stringlengths
28
2.42k
prob_desc_sample_outputs
stringlengths
2
796
source_code
stringlengths
42
65.5k
hidden_unit_tests
stringclasses
1 value
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
8d75c67aba11115071aef59cd2ba1ba3
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include<stdio.h> int main() { long int T,n,i,j,k,l,Sum=0,c; scanf("%ld",&T); for(i=0;i<T;i++) { c=0; scanf("%ld",&n); scanf("%ld",&k); long int ar[n]; long int br[n]; for(j=0;j<n;j++) { scanf("%ld",&ar[j]); if(c==k-1) { Sum=Sum+ar[j]; continue; } Sum=Sum+ar[j]; if(Sum%2!=0) { b...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
63bdff0eb5b118a8adcdadd6a9c2126f
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include <stdio.h> typedef long long ll; #define max(l,r) ((l)>(r)?l:r) #define min(l,r) ((l)<(r)?l:r) #define swap(l,r) {ll tp=l;l=r;r=tp;} #define rep(i,n) for(int i=0;i<(int)(n);i++) int n,t,k; int a[202020]; int solve(){ int ans = 0; int odd = 0; rep(i,n) if(a[i]%2) odd++; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
843abaa52c7a5aa3e5b14b5b4b8182d9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include <stdio.h> #define READ(n) int (n); scanf("%d",&(n)) #define getInt(a) scanf("%d", &a) #define FOR(i,L,R) for (int i = L; i < R; i++) int main(){ READ(q); while(q--){ READ(n); READ(k); int arr[n], oddCnt = 0; FOR(i, 0, n){ READ(a); arr[i] = a % 2; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
58c1c4c7a500e5f234cbe22847d56c51
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include<stdio.h> int main(){ int t; scanf("%d", &t); while(t--){ int n, k; scanf("%d %d", &n, &k); int a[n]; int b[n]; int count = 0; for(int i=0; i<n; i++){ scanf("%d", &a[i]); if(a[i]%2 == 1){ b[count] = i; count++; } } if(count >=k && k%2 == c...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
dc8e414860b0c72ba52fdb04dfe20008
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include<stdio.h> int main() { int q,n,k,a,b,i,o=0,t[200001],j=0; scanf("%d",&q); while(q--) { scanf("%d%d",&n,&k); for(i=0; i<n; i++) { scanf("%d",&a); if(a&1) o++,t[j++]=i+1; } if(o<k||((k+o)&1)) printf("NO\n")...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to...
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The di...
C
7f5269f3357827b9d8682d70befd3de1
ee73fb60e42e178afac280a47661fd2f
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "constructive algorithms", "math" ]
1563978900
["3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2"]
null
PASSED
1,200
standard input
3 seconds
The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectivel...
["YES\n1 3 5\nNO\nNO"]
#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,k,K[200000],o=0; scanf("%d %d",&n,&k); int a[200000]; long long sum=0; int i=0; while(i<n) { scanf("%d",&a[i]); sum=(long long)sum+a[i]; ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
3daf5000b5ebb47e754421ae8c987988
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> int main(void) { int n; int hh,mm; scanf("%d",&n); scanf("%d:%d", &hh, &mm); if( n == 12) { while(hh<1) hh+=10; while(hh>12) hh-=10; while(mm>=60) mm-=60; } else if( n == 24) { while(hh<...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
6491916d048e8aa381d1a1faa1f7b616
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
/* Problem: 722A - Broken Clock */ /* Solver: Gusztav Szmolik */ #include <stdio.h> #include <string.h> #include <ctype.h> int main () { unsigned short tf; unsigned char tm[7]; unsigned short h; unsigned short m; if (scanf("%hu",&tf) != 1) return -1; if (tf != 12 && tf != 24) ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
180a29068d293b57af3ed0144797026c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include<stdio.h> int main() { char h1, h2, m1, m2; int form; scanf("%d\n", &form); scanf("%c%c:%c%c", &h1,&h2,&m1,&m2); if (form == 12) { if (h1 > '1') { if (h2 != '0') { h1 = '0'; } else { h1 = '1'; } } if (h1 == '0'&&h2 == '0') { h2 = '1'; } if(h1 == '1'&&h2 > '2'){ h2 = '0...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
cb08db9b7a25fc2f6bf5655c903f1add
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> #include <stdlib.h> int main(void) { int format; char hh[3], mm[3]; scanf("%d\n", &format); hh[0]=getchar(); hh[1]=getchar(); getchar(); mm[0]=getchar(); mm[1]=getchar(); hh[2]='\0'; mm[2]='\0'; int m=atoi(mm), h=atoi(hh); if(m>59) mm[0]='0'; ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
2b338822baa846554fc9c1be6f51d941
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> #include <string.h> int main() { //freopen ("lel.in","r",stdin); int format; int h,m; scanf("%d",&format); scanf("%2d:%2d",&h,&m); if(format==24) { if(h>23) h=h%10; if(m>59) m=m%10; } else if(format==12) { if(h==0) h=1; if(h>12 && h%10!=0) h=h%10; else if(h>12) h=10; if(m...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
a6f3ada5415f077f7ffd35801b6f049a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include<stdio.h> int main() { int a,h,m; scanf ("%d\n", &a); a = a / 12; scanf ("%d:%d", &h, &m); if ( a == 1) { if (h > 12) h = h % 10; if (h == 0) h = 10; if (m > 59) m = m % 10; } else { if (h > 24) h = h % 10; if (h == 24) h = 14; if (m > 59) m = m % 10; } printf ("%02d:%02d", h, m ); ret...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
e6368f3076e5ac06a287a48281756e1c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> int main (){ int format,h1,h2,m1,m2,hh,mm; scanf ("%d",&format); scanf ("%1d%1d:%1d%1d",&h1,&h2,&m1,&m2); hh=h1*10+h2; mm=m1*10+m2; if (format==24){ if (hh>=24) h1=0; if (mm>=60) m1=0; }else { if (hh> 12) h1=0; if (mm>=60) m1=0; if (h1==0 && h2==0) ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
9b3fbfa2c4be558959c5d364aaa9700f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> int main(){ int n; char h1, h2, m1, m2; scanf("%d\n", &n); scanf("%c%c:%c%c", &h1, &h2, &m1, &m2); if(n == 24){ if(h1 == '2' && h2 > '3'){ h2 = '0'; } else if(h1 > '2'){ h1 = '0'; } } else{ if(h1 == '0' && h2 == '0'){ h1 = '1'; } else if(h1...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
ecd5079a190e9ebe11d31abe9e9f79eb
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include<stdio.h> int main() { int n; int a,b; scanf("%d",&n); scanf("%d:%d",&a,&b); if(n==24) { if(0<=a&&a<=23) { if(a<=9) printf("0"); printf("%d",a); } else { if(a/10==2) printf("20"); else { a%=10; printf("%d",10+a); } } } else if(n==12) { if(1<=a&&a<=12) ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
4a4917ba77eeaf7307328b5ae5ea656c
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> #include <stdlib.h> int main() { int stat; scanf("%d", &stat); char s[10]; scanf("%s", &s); if (s[3] > '5') s[3] = '5'; if (stat == 12){ if ((s[0] > '1') && (s[1] != '0')) s[0] = '0'; else if (s[1] == '0') s[0] = '1'; else if ((s[0] == '1') && (s[1] > ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
6194cad9500aac975311ac44b4f0ec9a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <stdio.h> int main() { int m; char s[100]; int hour=0, min = 0; scanf("%d", &m); scanf("%s", s); hour = 10 * (s[0] - '0') + s[1] - '0'; min = 10 * (s[3] - '0') + s[4] - '0'; if (m == 24) { if (hour > 23) hour %=10; if (min > 59) min %= 10; ...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
f01f02805dd75f194d9a60814463a755
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include<stdio.h> int main() { int f; int h, m; scanf("%d", &f); scanf("%d:%d", &h,&m); if(m>59) m=m%10; if(f==12){ if(h==0) h=1; if(h>12){ if(h%10==0) h=10; else h=h%10; } } else if(f...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
3376071714d819562e5b51580bf2e504
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include<stdio.h> int main() { int h,a,b,c,d; scanf("%d",&h); scanf("%1d%1d:%1d%1d",&a,&b,&c,&d); if(h==12) { if(a==1 && b>2) a=0; else if(b==0 && a>1) a=1; else if(a>1 && b>0) a=0; else if(a==0 && b==0) b=1; } if(h==24) { if(...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
87ead4856a67dde8cd389d230d098045
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> #include <string.h> char ss[7]; int main() { int t; scanf("%d", &t); scanf("%s", ss); if (ss[3] - '0' > 5) ss[3] = '5'; if (t == 12) { if (ss[0] == '0'&&ss[1] == '0') ss[1] = '1'; else if (ss[0] == '1'&&ss[1] - '0' > 2) ss[1] = '2'; else if (ss[0] - '0' > 1 && ss[1] - '0' <= 2) ss[0] = '1...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
fd404e93fcedc8fdeedb7ef90e9e3cba
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> //#define DEBUG int main(void) { #ifdef DEBUG freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int f; char t[10]; scanf("%d\n%s", &f, t); if (t[3] > '5') t[3] = '0'; if (f == 12) { if (t[0] == '0' && t[1] == '0') t[1] = '1'; else if (t[0] == '1...
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.You are given a time in format HH:MM that is currently displayed on the broken cl...
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.
C
88d56c1e3a7ffa94354ce0c70d8e958f
c0ca0a1d6fcc78541bc24e6388d55187
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1475330700
["24\n17:30", "12\n17:30", "24\n99:99"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.
["17:30", "07:30", "09:09"]
#include <stdio.h> int main() { int a, h1, h2; scanf("%d", &a); scanf("%d:%d", &h1, &h2); if (h2 > 59) h2 = h2 % 10; if (a == 12) if (h1 > 12||h1 == 0) if (h1%10 == 0) h1 = 10; else h1 = h1 % 10; if (a == 24) if (!(h1 <= 23)) h1 =h1 % 10; printf("%02d:%02d\n", h1, h2); return 0; }
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
4ed0d6fd1effbd3c5b64fd6a5c4fc066
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> #include<math.h> int cmp(const void*a,const void*b) { return *(int*)b-*(int*)a; } int main() { int i,j,k1=0,k2=0,k3=0,n,n1=0,n2=0,n3=0,judge=0; int c[5001],a[5001],b[5001],d[5001]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&c[i]); if(c[i]==1) { a[n1]=i+1; n1++; } else if(c[i]...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
506b46418a71b032acada012c3a6dd72
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> #include<math.h> int cmp(const void*a,const void*b) { return *(int*)b-*(int*)a; } int main() { int i,j,k,a,num,n,n1=0,n2=0,n3=0,judge=0; int c[5001],b[4][5001]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&c[i]); if(c[i]==1) { b[1][n1]=i+1; n1++; } else if(c[i]==2) { b[2][...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
b8eeb1bf65a68a336c6f5170184ce20b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> #include<math.h> int cmp(const void*a,const void*b) { return *(int*)b-*(int*)a; } int main() { int i,j,k,a,n,n1=0,n2=0,n3=0,judge=0; int c[5001],b[3][2],d[5001]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&c[i]); if(c[i]==1) { n1++; } else if(c[i]==2) { n2++; } else { ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
7083d4553353124078d639a35790ca2a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main() { int n,i,t,one[5002],two[5005],three[5005],on=0,tw=0,thr=0; scanf("%d",&n); for(i=1; i<=n; i++) { scanf("%d",&t); if(t==1) { on++; one[on]=i; } if(t==2) { tw++; two[tw]=i; ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
45237a8acfaae043554c384fe6b3b175
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main(){ int ones=0,twoes=0,threes=0; int n,checker,j=1,n1=0,n2=1,n3=2,w; scanf("%d",&n); int a[n*3]; for(int i=1;i<=n;i++){ scanf("%d",&checker); if(checker==1){ a[n1]=j; n1+=3; j++; ones++; } else if(checker==2){ a[n2]=j; n2+=3; j++; twoes++; } else{ a[n3]=j; ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
ad47f8056a6a7e98b4dfe67b64f36a0e
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> #include<stdlib.h> int main(void) { unsigned n,i,j,k,l,num,num1,num2,num3,*a,*b,*c,*t; scanf("%u",&n); t=(unsigned*)malloc(n*sizeof(unsigned)); a=(unsigned*)malloc((n)*sizeof(unsigned)); b=(unsigned*)malloc((n)*sizeof(unsigned)); c=(unsigned*)malloc((n)*sizeof(unsigned)); f...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
e77a1d5f0a5a379fc9dd0f0ae97547ad
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
// Codeforces A. Team Olympiad // Created by Abdulrahman Elsayed on 04/07/2020 #include <stdio.h> int min(int *a, int *b, int *c); int main() { int n, c1 = 0, c2 = 0, c3 = 0, teams = 0; scanf("%d", &n); int array[n]; int count1[n], count2[n], count3[n]; for (int i = 0; i < n; i++) ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
7f892cdfea0f0bb71ab92a61c88c5946
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> main(){ int n, i, j, input; scanf("%d", &n); int prog[n], math[n], sports[n], p=0, m=0, s=0, teams; for(i=0; i<n; i++){ scanf("%d", &input); // store the index if(input==1){ prog[p] = i+1; p++; }else if(input==2){ math[m] = i+1; m++; }else if(input==3){ sports[s] =...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
87db91479654336c44cdc297d1d2f91a
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> main(){ int n, i, input; scanf("%d", &n); int skills[3][n], p=0, m=0, s=0; for(i=0; i<n; i++){ scanf("%d", &input); // store the index if(input==1){ skills[0][p] = i+1; p++; }else if(input==2){ skills[1][m] = i+1; m++; }else if(input==3){ skills[2][s] = i+1; s++...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
e2ee8d99e2f0db9d6762c89d729fe026
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> main(){ int n, i, input; scanf("%d", &n); int skills[3][n], p=0, m=0, s=0, teams; for(i=0; i<n; i++){ scanf("%d", &input); // store the index if(input==1){ skills[0][p] = i+1; p++; }else if(input==2){ skills[1][m] = i+1; m++; }else if(input==3){ skills[2][s] = i+1;...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
6b8d078876733abf6be038e03d00ca18
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> main(){ int i,j,k,a[4],b[6000],n1,n,l,p,j1,j2,j3; scanf("%d",&n); a[1]=0;a[2]=0;a[3]=0; for(i=0;i<n;i++){ scanf("%d",&k); b[i]=k; a[k]=a[k]+1; } if(a[1]<=a[2] && a[1]<=a[3]) n1=a[1]; if(a[2]<=a[1] && a[2]<=a[3]) n1=a[2]; if(a[3]<=a[2] ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
2559d5acfdabd05d64d49220ad8ea035
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> int main() { int a,b,c,d=0,e=0,f=0,j=0,k,x=0,y=0,z=0,w=0,r=0,t=0; scanf("%d",&a); int s[a]; int i; for(i=1;i<=a;i++) { scanf("%d",&s[i]); if(s[i]==1) { d++; } else if(s[i]==2) { e++; }else { f++; } } if(d==0||e==0||f==0) { printf("0"); } else { ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
7310f1cbd987b810feb4258514316d09
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main() { int i,j,k,n,a[10000],u=0,o=0,p=0,q[10000],w[10000],e[10000],count,ct=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { count=0; if(a[i]==1) { for(j=0;j<n;j++) { if(a[j]==...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
7890ed9a13f13953dac54e766c81b2ec
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> int main() { int n; scanf("%d", &n); int a[n], i, b[4]={0}, min=5010; for(i=0; i<n; i++) { scanf("%d", &a[i]); b[a[i]]++; } for(i=1; i<4; i++) { if(b[i]<min) min = b[i]; } printf("%d\n", min); int p=0, q=0, r=0; for(i=0; i<min; i++) { while(a[p]!=1) p++; printf("%d ", ++p)...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
8d11fc7f24429840e0a3f04018938c4f
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> int cmp(void const* a,void const* b) { return (*(int *)a - *(int *)b); } int main() { int n; scanf("%d",&n); int i,o=0,t=0,p=0; int q; int cal[4]={0}; int one[5002]={0},two[5002]={0},three[5002]={0}; for(i=1;i<=n;i++) { scanf("%d",&q); cal[q]++; if(q==1) { on...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
c431977125f4d8fb0566bc864e03e3cc
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main() { int n,i,min; scanf("%d",&n); int a[n]; int freq[4]={0}; for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]==1) { freq[1]=freq[1]+1; } else if(a[i]==2) { freq[2]=freq[2]+1; } else ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
585b3e0161320024bb691112911cc320
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> int main() { int n; scanf("%d",&n); int a[5005]; int q1[5000],q2[5000],q3[5000]; int x=0,y=0,z=0; int min; for(int i=1; i<=n ; ++i){ scanf("%d",&a[i]); if(a[i]==1) { q1[x] = i; x=x+1; } if(a[i]==2) { ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
d6d76e99f66d46461273e7e964c6a3f9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> int mini (int a, int b) { return a > b ? b : a; } void teams(void) { int n; scanf("%d", &n); int arr[n]; int o = 0, t = 0, th = 0; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); if (arr[i] == 1) { o++; } else if (arr[i] == 2) { t++; } else if (arr[i] == ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
2d7800ad3f194308e701582a3dd55a25
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int a[5000],b[5000],c[5000],a1=0,b1=0,c1=0,n,m,i,j=0,k=0,l=0; int main(){ scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&m); if(m==1) a1++,a[j]=i,j++; else if(m==2) b1++,b[k]=i,k++; else if(m==3) c1++,c[l]=i,l++; } ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
57ae667eb7455cdccacc632c082a0135
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int min(int a,int b,int c){ if(a<=b && a<=c) return(a); else if(b<=a && b<=c) return(b); else if(c<=a && c<=b) return(c); } int a[5000],b[5000],c[5000],a1=0,b1=0,c1=0,n,m,i,j=0,k=0,l=0; int main(){ scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
b96547662726fb8985008064623c5da7
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main() { int n,a[5005],k,i,d,j,one=0,two=0,th=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]==1) one++; else if(a[i]==2) two++; else if(a[i]==3) th++; } if(one<two) { d=one; one=two; two=d; }i...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
abd62fadfecc833c3dfa8814f49ddd24
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> int nearestOne(int * childrenArray,int numberOfChildren); int nearestTwo(int * childrenArray,int numberOfChildren); int nearestThree(int * childrenArray,int numberOfChildren); int numberOfTeams(int * childrenArray,int numberOfChildren); void printIndex(int * childrenArray,int numb...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
e353d71fff4a3ed17f0aee67d42008b9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int nearestOne(int*, int); int nearestTwo(int*, int); int nearestThree(int*, int); int main() { int n; int* children; int one, two, three,numberOfTeams=0; int outputArray[5000]; scanf("%d", &n); children = (int*)malloc(n * sizeof(int)); ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
82aeddcd7549f56e9b1753d665ea9924
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> int nearestOne(int * childrenArray,int numberOfChildren); int nearestTwo(int * childrenArray,int numberOfChildren); int nearestThree(int * childrenArray,int numberOfChildren); int numberOfTeams(int * childrenArray,int numberOfChildren); void printIndex(int * childrenArray,int numb...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
c3b29f62ebf35c385b2fd1292f139102
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> #include<math.h> int main() { int n,i,x=0,y=0,z=0,l,m=0,j,p=0,o=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) { if(a[i]==1) x++; else if(a[i]==2) y++; else if(a[i]==3) z++; } if(x==0||y==0||z==0) printf("0"); else { if(x<y)...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
fc5a185011665182d7e5b53ecbb945e9
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int min(int i, int j, int k) { int x; x=i; if(j<x) x=j; if(k<x) x=k; return x; } int main() { int a[5000]; int p[5000],q[5000],r[5000]; int n,i; int x=0,y=0,z=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
a9b70553dcefd8aaa2237c1b2b49e168
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> int main(void) { int n; scanf("%d", &n); int students[3][5000]; int cnts[3] = {0, 0, 0}; for(int i = 0; i < n; i++) { int a; scanf("%d", &a); students[a-1][cnts[a-1]] = i+1; cnts[a-1]++; } int smallest = cnts[0]; for(int i = 1; ...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
db28aa183f5f7c078c71e6aed96d7a0e
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> int min(int k, int l, int m){ if(m<=k&&m<=l){ return m; } else if(k<=m&&k<=l){ return k; } else{ return l; } } int main() { int n,team[5001],i,onepost[5001],twopostion[5001],threepostion[5001],k=0,l=0,m=0,teamnumber; scanf("%d",&n);...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
46d1018a83deb2e3c7d70161937c2c65
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include <stdio.h> #include <stdlib.h> int main() { int num,i,j=0,k=0,l=0,array[5001],array1[5001],array2[5001],array3[5001],team; scanf("%d",&num); for(i=0;i<num;++i){ scanf("%d",&array[i]); } for(i=0;i<num;++i){ if(array[i]==1){ array1[j]=i; j++; } else if(array[i]==2){ array2...
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti: ti = 1, if the i-th child is good at programming, ti = 2,...
In the first line output integer w — the largest possible number of teams. Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in...
C
c014861f27edf35990cc065399697b10
195b48cbf3b97fcd137f8969e99e0c97
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "implementation", "sortings", "greedy" ]
1416733800
["7\n1 3 1 3 2 1 2", "4\n2 1 1 2"]
null
PASSED
800
standard input
1 second
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.
["2\n3 5 2\n6 7 4", "0"]
#include<stdio.h> int main() { int n,t[10000],a=0,b=0,c=0,i,p,e[10000],f[10000],g[10000]; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&t[i]); if(t[i]==1) { e[a]=i; a++; } else if(t[i]==2) { f[b]=i; b++; ...
There is a country with $$$n$$$ citizens. The $$$i$$$-th of them initially has $$$a_{i}$$$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.Somet...
Print $$$n$$$ integers — the balances of all citizens after all events.
C
7b788c660fb8ca703af0030f4c84ce96
852ee8d505f20c21fe2e2d8041546906
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "data structures", "binary search", "sortings", "brute force" ]
1564497300
["4\n1 2 3 4\n3\n2 3\n1 2 2\n2 1", "5\n3 50 2 1 10\n3\n1 2 0\n2 8\n1 3 20"]
NoteIn the first example the balances change as follows: 1 2 3 4 $$$\rightarrow$$$ 3 3 3 4 $$$\rightarrow$$$ 3 2 3 4 $$$\rightarrow$$$ 3 2 3 4In the second example the balances change as follows: 3 50 2 1 10 $$$\rightarrow$$$ 3 0 2 1 10 $$$\rightarrow$$$ 8 8 8 8 10 $$$\rightarrow$$$ 8 8 20 8 10
PASSED
1,600
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^{5}$$$) — the numer of citizens. The next line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0 \le a_{i} \le 10^{9}$$$) — the initial balances of citizens. The next line contains a single integer $$$q$$$ ($$$1 \le q \le 2 \...
["3 2 3 4", "8 8 20 8 10"]
#include<stdio.h> #define MAX(a,b) a>b?a:b int tc[200000],x[200000]; int main() { int n; scanf("%d",&n); int current[n],i; for(i=0; i<n; i++) scanf("%d",&current[i]); int q; scanf("%d",&q); int serial,max=0,t,tx; for(i=0; i<q; i++) { scanf("%d",&serial); if(se...
There is a country with $$$n$$$ citizens. The $$$i$$$-th of them initially has $$$a_{i}$$$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.Somet...
Print $$$n$$$ integers — the balances of all citizens after all events.
C
7b788c660fb8ca703af0030f4c84ce96
1fe8af35dbbc4c82f2a871becd0f835b
GNU C11
standard output
256 megabytes
train_000.jsonl
[ "data structures", "binary search", "sortings", "brute force" ]
1564497300
["4\n1 2 3 4\n3\n2 3\n1 2 2\n2 1", "5\n3 50 2 1 10\n3\n1 2 0\n2 8\n1 3 20"]
NoteIn the first example the balances change as follows: 1 2 3 4 $$$\rightarrow$$$ 3 3 3 4 $$$\rightarrow$$$ 3 2 3 4 $$$\rightarrow$$$ 3 2 3 4In the second example the balances change as follows: 3 50 2 1 10 $$$\rightarrow$$$ 3 0 2 1 10 $$$\rightarrow$$$ 8 8 8 8 10 $$$\rightarrow$$$ 8 8 20 8 10
PASSED
1,600
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^{5}$$$) — the numer of citizens. The next line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0 \le a_{i} \le 10^{9}$$$) — the initial balances of citizens. The next line contains a single integer $$$q$$$ ($$$1 \le q \le 2 \...
["3 2 3 4", "8 8 20 8 10"]
#include<stdio.h> #define MAX(a,b) a>b?a:b int tc[200000],x[200000]; int main() { int n; scanf("%d",&n); int current[n],i; for(i=0; i<n; i++) scanf("%d",&current[i]); int q; scanf("%d",&q); int serial,max=0,t,tx; for(i=0; i<q; i++) { scanf("%d",&serial); if(se...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
9af15124a2eda317f02851efadfb158f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> #include<string.h> int main() { int n, i, j, count = 0; scanf ("%d", &n); char str[n][102]; for (i = 0; i < n; i++) { scanf ("%s", str[i]); } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if ((j + 1) < n && str[i][j + 1]=='o') ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
18190a2e4bc0845f4d7473974f862bd9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main(){ int n; scanf("%d", &n); int i, j; char a[102][102]; for (i = 1; i <= n; i++) scanf("%s", a[i]); for (i = 1; i <= n; i++) for (j = n; j > 0; j--) a[i][j] = a[i][j-1]; for (i = 1; i <= n; i++){ a[0][i] = 'a'; a[n+1][i]...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
bcd09fbf55eaa5d57283e5dd185ea73a
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main(){ int n; scanf("%d", &n); int i, j; char a[1002][1002]; for (i = 1; i <= n; i++) scanf("%s", a[i]); for (i = 1; i <= n; i++) for (j = n; j > 0; j--) a[i][j] = a[i][j-1]; for (i = 1; i <= n; i++){ a[0][i] = 'a'; a[n+1][...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
bf29f3150eeb29803f093b532a3d9f8d
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<Stdio.h> int main() { int i,j,n,c=0; scanf("%d",&n); char s[105],a[n][n]; for(i=0;i<n;i++) { scanf("%s",s); for(j=0;j<n;j++) a[i][j]=s[j]; } for(i=0;i<n;i++) for(j=0;j<n;j++) { c=0; if(a[i-1][j]=='o'&&i>0) ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
c689be621e26d936dcc6e2fd8b98e065
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main() { int n, i, j; char a[105][105]; scanf("%d", &n); for(i=0; i<n; i++) scanf("%s", &a[i]); int flag=0, sum; for(i=0; i<n; i++) { for(j=0; j<n; j++) { sum=0; if(a[i][j+1]=='o') sum++; if(a[...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
4990d1f5558fb7041f5cac14bdbafed3
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,j,count=0; scanf("%d",&n); char a[n+1][n+1]; for(i=0;i<n;i++) { scanf("%s",&a[i]); } int flag =0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { count =0; if(i-1>=0) { if(a[i-1][j]=='o') ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
83c85093139c0233d629a54b5ea997c4
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main() { int n, k, i, j, flag, count; char a[111][111]; scanf ("%d", &n); for (i = 0; i < n; i++) { scanf ("%c", &k); for (j = 0; j < n; j++) { scanf ("%c", &a[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) {...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
98c8ac51cb3f1ce37d8693b11cf96f03
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int i,j,n,c=0; char a[101][101]; int main() { scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf(" %c",&a[i][j]); } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i-1][j]=='o' && i-1>=0 ) c++; if(a[i][j-1]=='o' && j-1>=0) c+...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
3944af2d1e289f1cc6e6ecd84b3df9e9
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int i,j,n,c=0; char a[101][101]; int main() { scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf(" %c",&a[i][j]); } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i-1][j]=='o' && i>=1 ) c++; if(a[i][j-1]=='o' && j>=1) c++; ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
ac6f9542b22e1d2c387028a1b707c142
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #include <stdlib.h> int main() { int n,i,j,ocount=0; char c[100][100]; scanf("%d ",&n); for(i=0;i<n;i++) { scanf("%s",c[i]); } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if((i < (n-1)) && (c[i+1][j] == 'o')) { ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
286302edcedf6b820df881b305ae7585
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main() { int n,i,j; scanf("%d",&n); int a[n][n]; getchar(); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { char temp; scanf("%c",&temp); if (temp == 'x') a[i][j] = 1; else a[i][j] = 0; } getchar(); } int ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
60d0511909705592fa99616de30a8519
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> char arr[250][250]; int main(){ int a; scanf("%d",&a); getchar(); int i,b; for(i=0;i<a;i++){ for(b=0;b<a;b++){ scanf("%c",&arr[i][b]); } getchar(); } for(i=0;i<a;i++){ int cnt=0; for(b=0;b<a;b++...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
5b3ee389e2c5aaa57345560660f70437
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int i,j,c=0,flag=0; int n; scanf("%d",&n); getchar(); char a[n][n]; for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%c",&a[i][j]); // printf("%c",a[i][j]); } getchar(); // printf("\n"); } for(...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
a768afb53a263801c0c8e694621e176f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
/* Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him? Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
adb188a63d791fd6e6de2c598dcb7477
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,p,q,r,s,sum,j; char a[101][101]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%s",a[i]); for(i=0;i<n;i++) { for(j=0;j<n;j++) { sum=0; p=j-1; q=j+1; r=i-1; s=i+1; if(p...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
b0f633037732103f26bb153751712ffe
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int n, i, j, sum; char a[105][105]; int main () { scanf("%d",&n); for(i = 1 ; i <= n ; i++) for(j = 1 ; j <= n ; j++) scanf(" %c",&a[i][j]); for(i = 1 ; i <= n ; i++) for(j = 1 ; j <= n ; j++, sum = 0){ if(a[i-1][j] == 'o')sum++; if(a[i+1][j] == 'o')sum++; if(a[i][j-1] == 'o')sum...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
76710c1f30404acca17ab6fa65eca4c3
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #define MAXN 100 typedef enum bool {FALSE,TRUE} bool; int n; int a [MAXN+2][MAXN+2]; int main (void) { scanf("%d",&n); int i, j; char s [MAXN+1]; for (i=1; i<=n; i++) { scanf("%s",s); for (j=1; j<=n; j++) { if (s[j-1]=='x') a[i][j] = 0; else a[i][j] = 1; } } for (i=0; i<...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
3f5320140f4138039c95c7dac5015260
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> char c[101][101]; int main(){ int n, sum = 0, i, j; scanf("%d", &n); for(i=0; i<n; i++){ for(j=0; j<n; j++){ scanf("%c", &c[i][j]); if(c[i][j] == '\n') scanf("%c", &c[i][j]); } } for(i=0; i<n; i++){ for(j=0; j<n; j++)...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
825c47e354a4fc0322aebf7642fa6226
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,j; scanf("%d",&n); char a[101][101]; for(i=0;i<n;i++) { scanf(" %s",a[i]); } int count; for(i=0;i<n;i++) { for(j=0;j<n;j++) { count=0; if(i-1>=0 && a[i-1][j]=='o')count++; if(i+1<n && a[i+1][j]=='o')count++; if(j-1>=0 && a[i][j-1]=='o')count++; if(j...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
f7f5f867957e4c52b1bada7af385c87f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { char ch; int i,j,n,cnt,flag=0; char mat[101][101]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",mat[i]); } /*for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%c",mat[i][j]); } printf("\n"); }*/ for(i=0;i<n;i++) { for(j=0;j<n;j++) { cnt=0; if((i-1)>=0 && mat[i-1][j]=='o') { cnt++; } if((j-1)...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
e17a2657588577204d8d81b0cfb17226
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,j,p=0,q=0,count=0,count1=0; char A[101][101]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("\n"); for(j=0;j<n;j++) { scanf("%c",&A[i][j]); } } if(n==1) { printf("YES"); return 0; } for(...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
b07191d0669a983060881560c52a2819
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,j,p=0,q=0,count=0,count1=0; char A[101][101]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("\n"); for(j=0;j<n;j++) { scanf("%c",&A[i][j]); } } if(n==1) { printf("YES"); return 0; } for(i=0;i<n;i++) { for(j=0;j<n;j++) { count=0; if(i>0) { if(A...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
9be99d7ff59694e43fefda2b642d15c7
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> #include<string.h> #define loop(i,a,b) for(int i=a;i<b;i++) int main(){ int n,t; scanf("%d",&n); char cb[n][n]; loop(i,0,n){ scanf("%s",cb[i]); } loop(i,0,n){ loop(j,0,n){ t=0; if(i-1>=0){ if(cb[i-1][j]=='o'){ t++; } } if(i<n-1){ ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
a068ab2ef37d4d686202fc7f37a77fbb
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> char ar[100][100]; int check_horizontal(int a, int b,int n) { int counter=0; if((b-1)>=0 && ar[a][b-1]=='o') counter++; if((a-1)>=0 && ar[a-1][b]=='o') counter++; if((b+1)<=(n-1) && ar[a][b+1]=='o') counter++; if((a+1)<=(n-1) && ar[a+1][b]=='o') counter++; return counter; } int check_possibl...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
4cf2ff28149330a44938685f560b626b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main () { int i ,n , j; char c[100][101] ; scanf ("%d" , &n) ; int counter ; for(i = 0; i < n; ++i) scanf ("%s" , c[i] ) ; for(i = 0; i < n; ++i){ counter= 0; for(j = 0; j < n; ++j){ if ( i -1 >= 0 ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
24074e193bafcd966a12d804557f30b5
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #include <string.h> int main() { int i, j, k, l, m, n; scanf("%d", &n); char a[n][n + 1]; for(i = 0; i < n; i++) { scanf("%s", a[i]); } for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { k = 0; if(i+1 < n && a[i + 1][j] =...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
8a9ed61bd4a26b133697f3945e1a4c77
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #include <string.h> int main(){ char p[101][101] ; int i , j, k=0 , n ; scanf("%d", &n) ; for(i=0;i<n;i++){ scanf("%s", &p[i]) ; } for(i=0;i < n;i++){ k= 0 ; for(j=0;j<n;j++){ if(p[i+1][j] == 'o'){ k++ ; // p...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
6a53db393e0242b7d8440dda84011c24
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> int main (int argc, char * argv[]) { int n; scanf ("%d\n", &n); char black_hole; char ** board = (char **) malloc (sizeof(char *) * n); for (int i = 0; i < n; i++) { board[i] = (char *) malloc (sizeof(char) * n); for (int ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
14871fa7b5531bc8bc28e4c6abd2da0b
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> char mat[101][101]; int main() { int n; scanf("%d", &n); int i, j, a=0; for(i=0; i<n; i++) { scanf("%s", &mat[i]); } for(i=0; i<n-1; i++) { a=0; for(j=0; j<n; j++) { if(mat[i+1][j]=='o') a++; ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
7e84ce58351dd1c23a2654a251a98421
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main() { char tempc; int a[104][104] = {0}; int i, flag = 0, n, j, temp; // STDIN scanf("%d\n", &n); for(i=1; i<=n; i++) { for(j=1; j<=n; j++) { scanf("%c", &tempc); if(tempc == 'o') a[i][j] = 1; } scanf("%c", &temp); } // GO ON for(i=1; i<=n; i++) for(j=1; j<=n; j++) ...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
a9594c7f6463237337972a5680699283
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> int main() { int i, j, n, cnt, yes; static char a[100][101]; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%s", a[i]); yes = 1; for (i = 0; i < n; i++) for (j = 0; j < n; j++) { cnt = 0; if (i > 0 && a[i - 1][j] == 'o') cnt++; if (i + 1 < n && a[i + 1][j] == 'o') cnt+...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
96aded186d02618af37be46a664ec299
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include<stdio.h> int main() { int n,i,j,c=0,count,u; char chk[100][100]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s",&chk[i]); } for(i=0;i<n;i++) { for(j=0;j<n;j++) { count=0; if((i-1>=0)&&(chk[i-1][j]=='o')) count++;...
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the ...
Print "YES" or "NO" (without the quotes) depending on the answer to the problem.
C
03fcf7402397b94edd1d1837e429185d
83742a6ad175a930904295cc6b29380f
GNU C
standard output
256 megabytes
train_000.jsonl
[ "implementation", "brute force" ]
1409061600
["3\nxxo\nxox\noxx", "4\nxxxo\nxoxo\noxox\nxxxx"]
null
PASSED
1,000
standard input
1 second
The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.
["YES", "NO"]
#include <stdio.h> #include <stdlib.h> int main() { int n, i, j, k; scanf("%d", &n); char c[n][n+1]; for (i = 0; i < n; ++i) { scanf("%s", &c[i]); } for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { k = 0; if (i == 0) { if (j == 0) { if (c[i][j+1] == 'o') { k++; }...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
92c1e21e52118048d37bb1090c9ce58d
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*traverse; int swap(int *a,int *b){...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
76f03ac09949f74f113ff97e51c71140
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct minheap* heap; struct adjacencylist *graph[100002],*traverse; int ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
935b226cde59743816be7a4a5d1eced8
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*traverse; int swap(int *a,int *b){ ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
05b55ec6e547a14ad38bd63c0a5b60b0
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*traverse; int swap(int *a,int *b){ ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
21eb9c734b08ea7f87f0cce1aa2423c1
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*traverse; int swap(int *a,int *b){ ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
39beac03da2c4cce02fecd8e083b7fa0
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct minheap* heap; struct adjacencylist *graph[100002],*traverse; int ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
5f9ad3f2486546fc964ca06b2a128e28
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
//OLD CODE WITHOUT FUNCTION #include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*travers...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
b603f3dd3a7c304e963721c0fe8d50c2
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
//Testing somebody's code #include <stdio.h> #include <stdlib.h> #define MAX 100005 #define ll long long #define M 0x7f7f7f7f7f7f7f7f // 有向边 typedef struct node{ // 终点 int e; // 权值 int w; // 指向下一个边的下标 int next; }Edge; // 用来保存边的链表 Edge edges[MAX<<2]; // 记录图上的每一个点能到边的链表的头位置 int first[MAX]; // 最短...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
9d3b57e97511d1d745311b376f46c933
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
//Testing Somebody's code #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 222222 typedef long long ll; typedef struct {ll v, w;} pair; typedef struct _list{ pair p; struct _list *next; } list; list *g[N]; ll n, m, u, v, w, size, dist[N], prev[N]; pai...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
a1b6861ce734515b888c58ba7bd935e8
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
//OLD CODE WITHOUT FUNCTION #include <stdio.h> #include <string.h> #include <limits.h> #include <stdlib.h> #define int long long int struct adjacencylist { int nodeindex; int weight; struct adjacencylist* adj; }; struct minheap { int mindist; int vertex; }; struct adjacencylist *graph[100002],*travers...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
b840a1c9c6434e7cefc4480a343c0111
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int to; int len; } edge; typedef struct { edge* vec; int size; int max_size; } vector; vector* vector_new() { vector* vec = calloc(1, sizeof(*vec)); return vec; } void vector_free(vector* vec) { free(vec->vec); free(vec); ...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
470a561ee26ec3fb2700d4cea4f8c742
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 222222 typedef long long ll; typedef struct {ll v, w;} pair; typedef struct _list{ pair p; struct _list *next; } list; list *g[N]; ll n, m, u, v, w, size, dist[N], prev[N]; pair pq[N]; void min_heapify(...
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.
C
bda2ca1fd65084bb9d8659c0a591743d
19ddbe733c809c4ff497e55871028504
GNU C11
standard output
64 megabytes
train_000.jsonl
[ "shortest paths", "graphs" ]
1276875000
["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1"]
null
PASSED
1,900
standard input
1 second
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge. It is possible that the...
["1 4 3 5", "1 4 3 5"]
#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 222222 typedef long long ll; typedef struct {ll v, w;} pair; typedef struct _list{ pair p; struct _list *next; } list; list *g[N]; ll n, m, a, b, w, size, dist[N], prev[N], ans[N], ind; pair pq[N]; void...