21 条题解

  • 0
    @ 2026-7-4 16:48:37

    #include <bits/stdc++.h> using namespace std; long long t; int main() { freopen("LoopPatrol.in","w",stdin); freopen("LoopPatrol.out","r",stdout); long long x=0, y=0, a=0, b=0; string s; cin >> s; cin >> t; int i=s.size(); for(int j = 0; j < i; ++j) { char c = s[j]; if (c=='E') { x++; } else if(c=='W') { x--; } else if(c=='N') { y++; } else if(c=='S') { y--; } } long long f=t/i; long long r=t%i; a=fx; b=fy; for (int j = 0; j < r; ++j) { char c = s[j]; if (c=='E') { a++; } else if(c=='W') { a--; } else if(c=='N') { b++; } else if(c=='S') { b--; } } cout << a << " " << b; return 0; }

    信息

    ID
    2
    时间
    1000ms
    内存
    128MiB
    难度
    8
    标签
    递交数
    3736
    已通过
    602
    上传者