mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-11-06 06:43:49 +00:00
feat: 添加测试代码和P1563问题解决方案
添加test.cpp的打印功能实现 新增P1563.cpp解决算法问题
This commit is contained in:
parent
197e613574
commit
abf764a938
31
src/11/5/P1563.cpp
Normal file
31
src/11/5/P1563.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <string>
|
||||
using ll = int64_t;
|
||||
#define printf
|
||||
const ll maxn = 1e5+7;
|
||||
ll n,m,ans;
|
||||
struct S{
|
||||
int op;
|
||||
std::string s;
|
||||
}s[maxn];
|
||||
|
||||
int main(){
|
||||
std::iostream::sync_with_stdio(false);
|
||||
std::cin.tie(nullptr);
|
||||
|
||||
std::cin>>n>>m;
|
||||
for(ll i=0;i<n;i++){
|
||||
std::cin>>s[i].op>>s[i].s;
|
||||
s[i].op=s[i].op==0?1:-1;
|
||||
}
|
||||
for(ll i=1;i<=m;i++){
|
||||
ll a,b;
|
||||
std::cin>>a>>b;
|
||||
a=a==0?-1:1;
|
||||
ans=(ans+a*s[(ans%n+n)%n].op*b)%n;
|
||||
printf("ans=%lld\n",ans);
|
||||
}
|
||||
std::cout<<s[(ans%n+n)%n].s<<"\n";
|
||||
}
|
||||
@ -1,3 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <print>
|
||||
#include <source_location>
|
||||
int main(){
|
||||
|
||||
std::println("hello world from {}\n",std::source_location().file_name());
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user