Common Board| Show all threads Hide all threads Show all messages Hide all messages | | What is the WA #3 | Sunnat | 2071. Juice Cocktails | 2 Nov 2015 18:03 | 1 | My solution is depend on next_permutation in C++. | | Idea | Felix_Mate | 1181. Cutting a Painted Polygon | 2 Nov 2015 17:44 | 2 | Idea Felix_Mate 21 Aug 2015 09:56 I got AC with O(N*N); Idea: use mathematical induction and prove that solution exist always. Induction gives a solution. Good hint! Furthermore, it can be proved that if it is not 'obviously impossible', then there will always be a solution. | | Wrong test #6 help me friends please !!! | Jamshid Sattarov (TUIT Urgench) | 1493. One Step from Happiness | 2 Nov 2015 00:37 | 2 | this is my solution #include <iostream> #include <cmath> using namespace std; int main() { long long a,b,s=0,d=0,k=0,jama,kk=0,ss=0,dd=0; cin>>b; a=b; b=b-1; while(b-1>0) { jama=b%10; k++; if(k<=3) { s+=jama; } else{ d+=jama; } b/=10; } int i=0; if(s-d==0 ) { i++; } a=a+1; int joma; while(a>0) { joma=a%10; kk++; if(kk<=3) { ss+=joma; } else{ dd+=joma; } a/=10; } if(ss-dd==0 ) { i++; } if(i>0) { cout<< "Yes"; } else cout<< "No"; return 0; } [delete] Edited by author 02.11.2015 00:38 Edited by author 02.11.2015 00:38 | | Accepted (Visual C++) | Vensus | 1243. Divorce of the Seven Dwarfs | 2 Nov 2015 00:01 | 3 | #include <iostream> using namespace std; int main() { int k = 0; long long int s = 0; char num[52]; int arr[51]; bool flag = true; cin >> num; for(int i = 0; flag; i++) { switch(num[i]) { case '0': { arr[i] = 0; k++; break; } case '1': { arr[i] = 1; k++; break; } case '2': { arr[i] = 2; k++; break; } case '3': { arr[i] = 3; k++; break; } case '4': { arr[i] = 4; k++; break; } case '5': { arr[i] = 5; k++; break; } case '6': { arr[i] = 6; k++; break; } case '7': { arr[i] = 7; k++; break; } case '8': { arr[i] = 8; k++; break; } case '9': { arr[i] = 9; k++; break; } case '\0': { flag = false; break; } } } for(int i = k-1; i+1 > 6;) { s = s + arr[i]; s = s + arr[i-1]*3; s = s + arr[i-2]*2; s = s + arr[i-3]*6; s = s + arr[i-4]*4; s = s + arr[i-5]*5; i = i - 6; k = k - 6; } if(k > 0) { s = s + arr[k-1]; k--; } if(k > 0) { s = s + arr[k-1]*3; k--; } if(k > 0) { s = s + arr[k-1]*2; k--; } if(k > 0) { s = s + arr[k-1]*6; k--; } if(k > 0) { s = s + arr[k-1]*4; k--; } if(k > 0) { s = s + arr[k-1]*5; k--; } cout << s%7; return 0; } Edited by author 16.11.2013 14:57 Edited by author 16.11.2013 14:57 Thats all ;) char c,ans; main(){ for(;(c=getchar())!='\n';ans=(ans*10+c-'0')%7); printf("%u\n",ans);
return 0; } | | WA3???...........Plz help | alok13alok | 1893. A380 | 1 Nov 2015 22:27 | 2 | import java.util.Scanner; public class A380 { public static void main(String agrs[]){ Scanner sys=new Scanner(System.in); String input=sys.next(); String[] part=input.split("(?<=\\d)(?=\\D)"); int num=Integer.parseInt(part[0]); if(num==1 || num==2){ if(part[1].equals("A")||part[1].equals("D")) System.out.println("window"); else if(part[1].equals("B")||part[1].equals("C")) System.out.println("aisle");
} else if(num>=3 && num<=20){ if(part[1].equals("A")||part[1].equals("F")) System.out.println("window"); else if(part[1].equals("B")||part[1].equals("C") || part[1].equals("D")||part[1].equals("E")) System.out.println("aisle");
} else if(num>=21 && num<=65){ if(part[1].equals("A")||part[1].equals("K")) System.out.println("window"); else if(part[1].equals("C")||part[1].equals("D") || part[1].equals("H")||part[1].equals("G")) System.out.println("aisle"); else if(part[1].equals("B")||part[1].equals("E") || part[1].equals("F")||part[1].equals("J")) System.out.println("niether"); }
} } | | Test 11, Execution time 0.187 s and TLE ?? | Radek | 1100. Final Standings | 1 Nov 2015 18:36 | 4 | Time limit is 1.0s, my program executes test 11 in 0.187s the result is TLE, why ? After conversion my program from C# to Java(with which I am not familiar) I have AC. Thus I think that there is a problem with C# judge for this problem. Yeah, I have the same problem. May be array, u give 150000. But need one more. +1 | | WHAT'S TEST 4? | invokerj | 2000. Grand Theft Array V | 1 Nov 2015 18:12 | 4 | I can't pass test 4, I just can't,,,,, thanks,, problem founded.... Edited by author 29.11.2013 11:03 it's problem with first_pos == second_pos Additional tests for those who stuck here: Test #1 3 1 2 0 2 2 Result 3 0 Test #2 3 0 2 1 2 2 Result 3 0 My algo pass all test discribed in this forum branch, but I can't pass this test :( help me plz! | | Wrong answer c++ | Sunbro | 1876. Centipede's Morning | 1 Nov 2015 18:10 | 3 | #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; if (39+2*a>a+2*b) cout << 39+2*a; else;cout << 40+2*b; return 0; } if (39 + 2 * a> 40 + 2 * b)т.к правую ногу полностью обули take maximum of this two: ansa=a*2+39; ansb=b*2+40;
| | AC | DiG | 1585. Penguins | 1 Nov 2015 17:22 | 2 | Enjoy: var n:1..1000; i,e,l,m:1..1000; s:string[1]; begin readln(n); for i:=1 to n do begin readln(s); if s[1]='E' then inc(e); if s[1]='L' then inc(l); if s[1]='M' then inc(m); end; if (e>=l) and (e>=m) then writeln('Emperor Penguin'); if (l>=e) and (l>=m) then writeln('Little Penguin'); if (m>=e) and (m>=l) then writeln('Macaroni Penguin'); end. Good luck! My Solution: #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; string s,ss; int mx=-1; int e,l,m; main(){ scanf("%d",&n); while(n--){ cin>>s>>ss; for(int i=0; i < s.len; i++){ switch(s[i]){ case 'E':e++;break; case 'L':l++;break; case 'M':m++;break; } } } mx=max(mx,max(e,max(l,m))); if(mx==e) puts("Emperor Penguin"); else if(mx==l) puts("Little Penguin"); else if(mx==m) puts("Macaroni Penguin");
return 0; } | | C++ program!!! | yaho0o0 | 1263. Elections | 1 Nov 2015 17:04 | 5 | #include <iostream> #include <stdio.h> using namespace std; int main() { int br[10024],i,m; double n,a; float sum; cin>>n>>a; sum=100/a; for(i=1;i<=10024;i++) { br[i]=0; } for(i=1;i<=a;i++) { cin>>m; br[m]++; } for(i=1;i<=n;i++) {
printf("%.2lf",(br[i]*sum)); cout<<"%"<<endl; } return 0; } #include <iostream> #include <hash_map> using namespace std; int main(){ int N = 0, M = 0, temp = 0; cin>>N>>M; hash_map<int, int> hm; for(int i = 1; i < N + 1; i++){ hm.insert(make_pair(i, 0)); } for(int i = 1; i < M + 1; i++){ cin>>temp; hash_map<int, int>::iterator it = hm.begin(); it = hm.find(temp); (it->second)++; } for(int i = 1; i < N + 1; i++){ hash_map<int, int>::iterator it = hm.begin(); it = hm.find(i); int value = it->second; float value_ = value; float M_ = M; printf("%.2f", 100.0 * value/M_); cout<<"%"<<endl; } } #include <iostream> using namespace std; int main () { int a[10000],n,m,i,j; float p,br=0; cin>>n>>m; for (i=1;i<=m;i++) cin>>a[i]; for (i=1;i<=n;i++) { for (j=1;j<=m;j++) if (i==a[j]) br++; p=br/m; p=p*100; printf("%.2lf",p); cout<<"%"<<endl; br=0; } return 0; } Why it does not work? #include <iostream> #include <iomanip> using namespace std; int main(){ int N,M; cin>>N; cin>>M; double* arr= new double[N]; int i=0; int voice; while(i<M){ cin>>voice; arr[voice-1]=arr[voice-1]+1; i++; } i=0; while(i<N){ double s = arr[i]/M*100; cout<<fixed<<setprecision(2)<<s<<'%'<<endl; i++; } return 0; } Edited by author 29.04.2013 18:02 My solution: #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std; int n, m; int a[100110]; main(){ scanf("%d%d",&n,&m); for(int i=1; i <= m; i++){ int x; scanf("%d",&x); a[x]++; } for(int i=1; i <= n; i++){ printf("%.2lf",a[i]*100.0/m); puts("%"); }
return 0; } | | Whats the problem? WA #4 | ELDVN | 1581. Teamwork | 1 Nov 2015 14:28 | 2 | #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int a[1010]; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ int x; scanf("%d",&x); a[x]++; } for(int i=0; i <= 10; i++){ if(a[i] > 0) printf("%d %d ",a[i], i); }
return 0; } I write the same logic, but first my code got WA #4. Second is accept! Wtf ? :D #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int cnt=1,ans; int a[1010]; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ scanf("%d",&a[i]); } for(int i=1; i <= n; i++){ if(a[i]==a[i+1]){ cnt++; ans=a[i+1]; } else{ ans=a[i]; printf("%d %d ",cnt,ans); cnt=1; } }
return 0; } | | One more test (about WA4) | FatalityNT | 1146. Maximum Sum | 1 Nov 2015 13:31 | 2 | Firstly my solution got TLE#4. Next, I make mew solution with new idea, and got WA#4. Also, my 2nd solution makes mistake in this test: 4 0 -2 -1 0 9 2 -9 -2 -4 1 -1 1 -1 8 10 -2 answer is 18. It can help someone. P.S. forry for bad English. | | WA #5 | mikhsatyshev | 2023. Donald is a postman | 1 Nov 2015 13:09 | 6 | WA #5 mikhsatyshev 11 Oct 2014 14:13 What's wrong? Here is my code: var a,b,c:array [1..3,1..3] of string; d,s,i,j,j1,n,p:longint; x:string; begin a[1,1]:='Alice'; a[1,2]:='Ariel'; a[1,3]:='Aurora'; a[2,1]:='Phil'; a[2,2]:='Peter'; a[2,3]:='Olaf'; a[3,1]:='Phoebus'; a[3,2]:='Ralph'; a[3,3]:='Robin'; b[1,1]:='Bambi'; b[1,2]:='Belle'; b[1,3]:='Bolt'; b[2,1]:='Mulan'; b[2,2]:='Mowgli'; b[2,3]:='Mickey'; b[3,1]:='Silver'; b[3,2]:='Simba'; b[3,3]:='Stitch'; c[1,1]:='Dumbo'; c[1,2]:='Genie'; c[1,3]:='Jiminy'; c[2,1]:='Kuzko'; c[2,2]:='Kida'; c[2,3]:='Kenai'; c[3,1]:='Tarzan'; c[3,2]:='Tiana'; c[3,3]:='Winnic'; readln (n); s:=0; p:=1; for i:=1 to n do begin readln (x); for j:=1 to 3 do for j1:=1 to 3 do begin If x=a[j,j1] then d:=1; If x=b[j,j1] then d:=2; If x=c[j,j1] then d:=3; end; s:=s+abs (p-d); p:=d; end; writeln (s); end. Re: WA #5 olpetOdessaONU [1 2/3] 11 Oct 2014 17:58 Winnie, not Winnic Edited by author 11.10.2014 17:58 Edited by author 11.10.2014 17:58 Why so dufficult solution? You could use switch/case for only first letters! Switch? Ha! How about sets? No need for sets: First, initialize positions of the names: int m[256]; m['A'] = m['P'] = m['O'] = m['R'] = 1; m['B'] = m['M'] = m['S'] = 2; m['D'] = m['G'] = m['J'] = m['K'] = m['T'] = m['W'] = 3; Then check where we are: ... string s; cin >> s; char c = s[0]; if (m[c] != current_position) ... Edited by author 15.09.2015 02:21 Edited by author 15.09.2015 02:21 Edited by author 15.09.2015 02:22 Edited by author 15.09.2015 02:22 My solution: #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std; int n; string s; int step,cnt=1; int ans; main(){ scanf("%d",&n); for(int i=0; i < n; i++){ cin>>s; for(int j=0; j <s.len; j++){ switch(s[j]){ case 'A':case 'P':case 'O':case 'R':ans=1;break; case 'B':case 'M':case 'S':ans=2;break; case 'D':case 'G':case 'J':case 'K':case 'T':case 'W': ans=3;break; } } step+=abs(cnt-ans); cnt=ans; } printf("%d",step);
return 0; } | | Access violation, but works true om my pc! Help! | daniilmcrose | 1100. Final Standings | 1 Nov 2015 06:25 | 2 | #include <iostream> using namespace std; int main() { int** m; long n; cin>>n; m = new int*[n]; for (long i=0; i<n; i++) { m[i]=new int[2]; m[i][1]=-1; } for (long j=0; j<n; j++) { int g, t; cin>>g>>t; if (j==0) { m[0][0]=g; m[0][1]=t; continue; } else for (long i=0; i<=j; i++) {
if (m[i][1]==t) while (m[i][1]==t && i<j) i++; else if (m[i][1]>t && m[i][i]!=-1) continue;
if (i==j) { m[j][0]=g; m[j][1]=t; break; } { for (long p=j; p>i; p--) { m[p][0]=m[p-1][0]; m[p][1]=m[p-1][1]; } m[i][0]=g; m[i][1]=t; break; } break; } } for (int i=0; i<n ;i++) { cout<<m[i][0]<<" "<<m[i][1]<<'\n'; } delete[] *m; return 0; } Is not advisable to use dynamic memory. I recommend you use STL <vector> | | what's wrong! How caan help me? | Xalmuratov_Farrux | 1567. SMS-spam | 1 Nov 2015 02:31 | 3 | #include<iostream> #include<string.h> using namespace std; int main() { char s[1000]; long l=0; cin.getline(s, sizeof(s)); for(int i=1; i<=strlen(s); i++) switch (s[i]) { case 'a':l++; break; case 'd':l++; break; case 'g':l++; break; case 'j':l++; break; case 'm':l++; break; case 'p':l++; break; case 's':l++; break; case 'v':l++; break; case 'y':l++; break; case '.':l++; break; case 'b':l+=2; break; case 'e':l+=2; break; case 'h':l+=2; break; case 'k':l+=2; break; case 'n':l+=2; break; case 'q':l+=2; break; case 't':l+=2; break; case 'w':l+=2; break; case 'z':l+=2; break; case ',':l+=2; break; case ' ':l++; break; case 'c':l+=3; break; case 'f':l+=3; break; case 'i':l+=3; break; case 'l':l+=3; break; case 'o':l+=3; break; case 'r':l+=3; break; case 'u':l+=3; break; case 'x':l+=3; break; case '!':l+=3; break; default: l++; } cout << l; } char s[1000]; - change it on 1001 ( /0 is symbol ) #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
string s; int sum; main(){ getline(cin,s); for(int i=0; i < s.len; i++){ switch(s[i]){ case 'a':case'd':case 'g':case 'j':case 'm':case 'p':case 's':case 'v':case 'y':case '.':case ' ':sum+=1; break; case 'b':case'e':case 'h':case 'k':case 'n':case 'q':case 't':case 'w':case 'z':case ',':sum+=2; break; case 'c':case'f':case 'i':case 'l':case 'o':case 'r':case 'u':case 'x':case '!':sum+=3; break; } } printf("%d",sum);
return 0; } | | What's wrong with it? | Me | 1000. A+B Problem | 31 Oct 2015 21:27 | 3 | #include <iostream> using namespace std; void main() { int a, b; cin >> a >> b;
cout << "The sum is: " << output << endl; } You didn't declare output: #include <iostream> int main() { int a, b; std::cout << "Enter first number: "; std::cin >> a; std::cout << "Enter second number: "; std::cin >> b; int output = a + b; std::cout << "\nThe sum is: " << output << std::endl; return 0; } Edited by author 25.07.2014 23:23 Your program must read and print only the data that is required in the problem statement. For example, you musn't print "Enter first number: " or "The sum is: ". | | Have a any sample test to test #3 Wrong Answer | Soporboy Botirov [TUIT Urgench] | 2046. The First Day at School | 31 Oct 2015 10:47 | 1 | Edited by author 31.10.2015 10:48 | | why this site works very badly.... what is wrong with me???? i don't understand. i am trying submit my solution, but i cant | Adhambek | | 30 Oct 2015 23:17 | 1 | | | Help WA4 | sherbina_evgeniy | 1658. Sum of Digits | 30 Oct 2015 15:12 | 3 | Help WA4 sherbina_evgeniy 4 May 2015 02:56 I have WA4. I don't understand why? Give me some tests please, which will help me understand my mistake. Thank you. Please,I wa 4 ,too.Thanks. Me too!Please!Thx! Please,I wa 4 ,too.Thanks. | | #4 | zmj159 | 1288. Astrolocation | 29 Oct 2015 17:24 | 1 | #4 zmj159 29 Oct 2015 17:24 Perhaps #4 is about a test without the back wall. Here come some questions: 1. Should we assume the back wall to be located in the n+1 - th ? 2. It seems that the second scanning is from the back. So the FIRST maximum refers to the one who is leftmost or the rightmost? |
|
|