QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650284 | #7858. Basic Equation Solving | Mrlaolu# | WA | 0ms | 3560kb | C++23 | 1.1kb | 2024-10-18 14:26:43 | 2024-10-18 14:26:44 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
using PII = pair<int,int>;
struct s{
int p,a,cnt;
};
void solve(){
int n,x;cin >> n >> x;
vector<int>a(n);
for(int i = 0;i < n;++i)cin >> a[i];
queue<s>que;
int ans = 0;
vector<bool>vis(n+1);
vector<bool>pass(n+1);
vis[0] = 1,pass[0] = 1;
que.push({0,a[0],0});
while(que.size()){
s t = que.front();
que.pop();
cout << t.p << " " << t.a << " " << t.cnt << endl;
if((t.a + t.p) % n == x){ans = t.cnt + 1;break;}
if(!vis[(t.a + t.p) % n]){
vis[(t.a + t.p) % n] = 1;
que.push({(t.a + t.p) % n,a[(t.a + t.p) % n],t.cnt+1});
}
if(!pass[(t.a + t.p + 1) % n] && !vis[(t.a + t.p + 1) % n]){
pass[(t.a + t.p + 1) % n] = 1;
que.push({t.p,(t.a+1) % n,t.cnt+1});
}
}
cout << ans << endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _ = 1;
while(_--){
solve();
}
}
/*
5 2
3 0 0 4 0
7 6
0 1 1 2 0 0 0
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3560kb
input:
1 P=NP
output:
0 0 0 1
result:
wrong answer 1st lines differ - expected: '766136394', found: '0 0 0'