Show all threads Hide all threads Show all messages Hide all messages | HERE IS THE ANSWER | Exceptional | 2023. Donald is a postman | 9 Feb 2016 20:53 | 1 | #include <stdio.h> #include <math.h> #include <iostream> #include <string> using namespace std; int main(){ int n, l = 0; string s[10], t[10], r[10]; scanf("%d", &n); s[0] = "Alice"; s[1] = "Ariel"; s[2] = "Aurora"; s[3] = "Phil"; s[4] = "Peter"; s[5] = "Olaf"; s[6] = "Phoebus"; s[7] = "Ralph"; s[8] = "Robin"; t[0] = "Bambi"; t[1] = "Belle"; t[2] = "Bolt"; t[3] = "Mulan"; t[4] = "Mowgli"; t[5] = "Mickey"; t[6] = "Silver"; t[7] = "Simba"; t[8] = "Stitch"; r[0] = "Dumbo"; r[1] = "Genie"; r[2] = "Jiminy"; r[3] = "Kuzko"; r[4] = "Kida"; r[5] = "Kenai"; r[6] = "Tarzan"; r[7] = "Tiana"; r[8] = "Winnie"; string q[10010]; for(int i = 0; i <= n; i ++){ getline(cin, q[i]); } __int64 k[10010], len = 1, sum = 0; for(int i = 2; i <= n; i ++){ int kk = 0; for(int j = 0; j < 9 ; j ++){ if(q[i] == s[j]){ kk = 1; } if(q[i] == t[j]){ kk = 2; } if(q[i] == r[j]){ kk = 3; } } k[len] = kk; len ++; } k [0] = 1; for(int i = 1; i < len; i ++){ sum += fabs(k[i] - k[i + 1]); } cout << sum << endl; } | WA#6 can someone help me? | Julius | 2023. Donald is a postman | 24 Nov 2015 23:10 | 2 | can someone help me?, im trying search the error but i dont found nothing, greetings.. import java.io.PrintWriter; import java.util.Scanner; public class P{ public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out= new PrintWriter(System.out); int current=1,cont=0;
int n=in.nextInt(); in.nextLine(); for(int i=0;i<n;i++){ String lec; lec=in.nextLine();
if(lec.equals("Aurora") || lec.equals("Alice") ||lec.equals("Ariel") ||lec.equals("Phil")||lec.equals("Peter")||lec.equals("Olaf")||lec.equals("Phoebus")||lec.equals("Ralph")||lec.equals("Robin") ){ if(current==2){ cont=cont+1; } if(current==3){ cont=cont+2; } current=1; } if(lec.equals("Bambi") || lec.equals("Belle") ||lec.equals("Bolt") ||lec.equals("Mulan")||lec.equals("Mowglin")||lec.equals("Mickey")||lec.equals("Silver")||lec.equals("Simba")||lec.equals("Stitch")){ if(current!=2){ cont=cont+1; } current=2; } if(lec.equals("Dumbo") || lec.equals("Genie") ||lec.equals("Jiminy") ||lec.equals("Kuzko")||lec.equals("Kida")||lec.equals("Kenai")||lec.equals("Tarzan")||lec.equals("Tiana")||lec.equals("Winnie")){ if(current==2){ cont=cont+1; } if(current==1){ cont=cont+2; } current=3; } }
System.out.print(cont);
out.flush(); } } solved, just a error on lec.equals("Mowglin") to lec.equals("Mowgli") my bad | WA8 c++. Help please | BUTKO_VNU | 2023. Donald is a postman | 17 Nov 2015 11:26 | 1 | #include <iostream> using namespace std; int main() { char first[4] = { 'A', 'P', 'O', 'R' }; char second[3] = { 'B', 'M', 'S'}; int mail = 0; bool AF=false;//already find char *input=new char[200]; int steps=0,duck=1; cin >> mail; for (int i = 0; i < mail; i++) { cin >> input; for (int j = 0; j < 4;j++) { if (input[0] == first[j]&&!AF) { AF = true; if (duck == 1)break; if (duck == 2)steps++; if (duck == 3)steps += 2; duck = 1; break; } } if (!AF){ for (int j = 0; j < 3; j++) { if (input[0] == second[j] && !AF) { AF = true; if (duck == 2)break; else steps++; duck = 2; break; } } } if (!AF) { AF = true; if (duck == 3)break; if (duck == 2)steps++; if (duck == 1)steps += 2; duck = 3; } AF = false;
} cout << steps; return 0; } Edited by author 17.11.2015 11:26 I found a solution to my problem was laziness. When I described the search for the third block - the answer was accepted as correct. Apparently in the verification test on the 8th provide those names are not on the shelves. Edited by author 17.11.2015 11:35 | 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; } | can anyone please give the test case #5 | ajay thapliyal | 2023. Donald is a postman | 19 Sep 2015 13:39 | 1 | when i try different inputs my code seems to work fine,but i am stuck at test case #5,can anyone please post it? | Little trick: if you are getting W3, or W5 or whatever | Nodir NAZAROV Komilijonovich [TUIT-Karshi] | 2023. Donald is a postman | 19 Apr 2015 13:07 | 3 | use simple algorithm: - checks only initial. - keep state of previous - initial state of previous is 1, since postman is in leftmost case useful test cases: ---- 1 Bambi 1 (not 0, because he moves to second case with one step) ---- 1 Alice 0 ---- 1 Dumbo 2 --- WA 5, but test is true( sorry, because I don't know English:) Didn't get your testcase; if Bambi, Alice and Dumbo are the Kids, the answer should be 3, right? | Test #5? Whats wrong with my code? | Dormidont3 | 2023. Donald is a postman | 17 Jan 2015 18:53 | 1 | #include <iostream> #include <string> using namespace std; int main() { int a[1000]; int n,i,k; char Name; cin>>n; string B; k=0; for (i=0;i<n;i++){ cin>>B; Name=B[0]; if(Name=='A' or Name=='P' or Name=='O' or Name=='R') {a[i]=1;} else {if(Name=='B' or Name=='M' or Name=='S') {a[i]=2;} else {a[i]=3;}; } } k=a[0]-1;
for (i=1;i<n;i++){ if (a[i-i]<a[i]){ k=k+a[i]-a[i-1];} else { k=k+a[i-1]-a[i];}
} cout<<k; return 0;
} | TEST #3 | GALIAF95 | 2023. Donald is a postman | 20 Dec 2014 13:40 | 2 | Here is the code(c++), what is wrong? #include <iostream> #include <string> using namespace std; int main() { string name[1001]; int counter=0; int n,i=0; cin>>n; while(i<=n) { getline(cin,name[i]); if(i!=0) if(name[i-1][0]!=name[i][0]) if(name[i-1][0] == 'A' || name[i-1][0] == 'P'||name[i-1][0] == 'O'||name[i-1][0] == 'R') { if(name[i][0] == 'B' || name[i][0] == 'M'||name[i][0] == 'S') counter++; else counter+=2; } else if(name[i-1][0] == 'B' || name[i-1][0] == 'M'||name[i-1][0] == 'S') { counter++; } else if(name[i-1][0] == 'D' || name[i-1][0] == 'G'||name[i-1][0] == 'J'||name[i-1][0] == 'K'||name[i-1][0] == 'T'||name[i-1][0] == 'W') { if(name[i][0] == 'B' || name[i][0] == 'M'||name[i][0] == 'S') counter++; else counter+=2; } i++; } cout<<counter; } Use a map instead of many "if"s. | WA #5 | Someone Else | 2023. Donald is a postman | 20 Dec 2014 13:40 | 1 | WA #5 Someone Else 20 Dec 2014 13:40 Can someone give me test cases? I believe my solution works and tried with many possible inputs and I get the right result. I found that it is possible to have more than one input value on the same line. And now I fail to pass #5. Any test cases would be much appreciated. Edited by author 20.12.2014 13:42 | WA5( | Sonechko | 2023. Donald is a postman | 26 Nov 2014 19:59 | 1 | WA5( Sonechko 26 Nov 2014 19:59 Подскажите какие могут быть ошибки Please help me Edited by author 26.11.2014 19:59 Edited by author 26.11.2014 19:59 Edited by author 13.01.2015 16:12 | WA in Test #5? Whats wrong with my code? | Zafar Alizade | 2023. Donald is a postman | 19 Oct 2014 11:03 | 2 | names = ['Alice', 'Ariel', 'Aurora', 'Phil', 'Peter', 'Olaf', 'Phoebus', 'Ralph', 'Robin', 'Bambi', 'Belle', 'Bolt', 'Mulan', 'Mowgli', 'Mickey', 'Silver', 'Simba', 'Stitch', 'Dumbo', 'Genie', 'Jiminy', 'Kuzko', 'Kida', 'Kenai', 'Tarzan', 'Tiana', 'Winnie'] n = int(raw_input()) letters = ['Alice'] for i in range(0, n): letters.append(raw_input())
result = 0 for i in range(1, n+1): result += int(abs(names.index(letters[i]) - names.index(letters[i -1]))/9)
print result :) I found my mistake. Its AC now :) |
|
|