#include "grader.h"
#include "memory.h"
#include<bits/stdc++.h>
using namespace std;
#define NAME ""
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,val) memset(x,val,sizeof(x))
#define couf(x) cout << fixed << setprecision(x)
template<class T> T Abs(T &x) {return (x>=0 ? x : -x);};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b) {a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b) {a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e15;
const int INF = (int)1e9;
int firstPos[25],secondPos[25];
void play() {
mset(firstPos,-1);
mset(secondPos,-1);
for (int i = 1; i<=50; i++) {
char firstCh = faceup(i);
char secondCh = faceup(i+1);
if(firstPos[firstCh-'A']==-1) {
firstPos[firstCh]=i;
}
else secondPos[firstCh-'A']=i;
if(firstPos[secondCh-'A']==-1) {
firstPos[secondCh]=i+1;
}
else secondPos[secondCh-'A']=i+1;
}
for (int i = 0; i<=25; i++) {
faceup(firstPos[i]);
faceup(secondPos[i]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
memory.cpp: In function 'void play()':
memory.cpp:37:15: warning: iteration 25 invokes undefined behavior [-Waggressive-loop-optimizations]
37 | faceup(firstPos[i]);
| ~~~~~~^~~~~~~~~~~~~
memory.cpp:36:22: note: within this loop
36 | for (int i = 0; i<=25; i++) {
| ~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |