asim2005's blog

By asim2005, 4 years ago, In English

https://codeforces.net/problemset/problem/1323/A

I have found something confusing in this problem.

This is the solution mohammadmahdi.hamidzadeh wrote.

include <bits/stdc++.h>

using namespace std;

int main(){ int t;cin>>t;while(t--){ int n,a=0,x;cin>>n; for(int i=1;i<=n;i++){ cin>>x; if(x%2==0)a=i; } if(a)cout<<1<<endl<<a<<endl; else{ if(n==1)cout<<-1<<endl; else cout<<2<<endl<<1<<" "<<2<<endl; } } }

I changed a little bit in this code.

include <bits/stdc++.h>

using namespace std;

int main(){ int t; cin>>t; while(t--){ int n,a = 0,x; cin>>n; for(int i=1;i<=n;i++){ cin>>x; if(x%2==0)a=i; } if(a)cout<<1<<endl<<a<<endl; else{ if(n==1)cout<<-1<<endl; else cout<<2<<endl<<1<<" "<<2<<endl; } } return 0; } // This is my code

But after this change, the outputs I am getting are wrong. I cannot understand this.

My question is : Where did I messed up?

  • Vote: I like it
  • +7
  • Vote: I do not like it

»
4 years ago, # |
Rev. 2   Vote: I like it +18 Vote: I do not like it

Try to use codeforces markup to insert code in the post.

Hope that helps you explain your problem properly.

»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Next time either give links to submission, or use proper formatting to display code.